0

My code is:

require([
     // Require the basic chart class
    "dojox/charting/Chart",

    // Require the theme of our choosing
    "dojox/charting/themes/ThreeD",         

    // Charting plugins:
    "dojox/charting/widget/SelectableLegend",

    //  We want to plot Lines
    "dojox/charting/plot2d/Lines",                  
    //  We want to use Markers
    "dojox/charting/plot2d/Markers",

    //  We'll use default x/y axes
    "dojox/charting/axis2d/Default",

    "dojox/charting/action2d/Tooltip",
    "dojo/domReady!"
], function(Chart, theme,Legend, Line) {
    dojo.ready(function(){
            // When the DOM is ready and resources are loaded...         
            // Create the chart within it's "holding" node
            var chart = new Chart("chartNode");
        chart.title="Sales Revenue Trend";          

            // Set the theme
            chart.setTheme(theme);

            // Add the only/default plot
            chart.addPlot("default", {
            type: Line,labels:true,
            markers: true
            });


        var myLabelFunc = function(text, value, precision){
            if(text!="0")               
               return (parseFloat(text)/100000)+" lacs";
            else
               return text;
        };
            // Add axes
            chart.addAxis("x",{labels: labels,majorTickStep:1,rotation: -90,title:"Date", titleOrientation:"away", titleFont: "normal normal bold",titleFontColor: "black"});
            chart.addAxis("y", { vertical: true,minorLabels: false,minorTicks:true, fixLower: "major", fixUpper: "major",title:"Gross Revenue(INR)", titleFont: "normal normal bold",titleFontColor: "black",dropLabels: false, labelFunc: myLabelFunc});

            // Add the series of data
            for(i=0;i<cr.length;i++)
            {
            chart.addSeries(channels[i],cr[i]);
            }
        new dojox.charting.action2d.Tooltip(chart,"default");

            // Render the chart!
            chart.render();
            var legend = new Legend({ chart: chart }, "legend");
    });
});

Above code works well in all PC browsers as well as on iOS device. But the problem is on Android device. I had go through logcat of Android device and found that there is script error(detail error:11-24 19:20:53.854: E/Web Console(335): Error: scriptError at file:///android_asset/www/dojo/dojo/dojo.js:15). On PC browser, it doesn't show any error(debugged using firebug).

I tried to remove "dojox/charting/action2d/Tooltip" from require statement. And it worked on Android as well. But I need to display value of markers in chart using tooltip but it throws error. So, is there any solution?

1 Answer 1

1

I suspect you might face the issue that Android tools are not including files (or directories) starting with underscore in APKs. By including Tooltip you probably include some dependencies that start by underscore thus the issue.

You have two ways for fixing that you can either "build" your Dojo code (see Dojo tutorials in particular) removing any underscore in your file names.

Or you can tell Android tools to include files starting by underscore (see: https://code.google.com/p/android/issues/detail?id=5343#c40). I have not tested this and some people pretend this is not work. But I would say this is worth testing.

Note that doing a build is however a good idea because this will reduce the number of files to be loaded at application startup improving the startup time.

Not the answer you're looking for? Browse other questions tagged or ask your own question.