Search code examples
dojolegenddojox.charting

Dojo 1.5.0 Charting Legend missing


I just upgraded from Dojo 1.4.3 to 1.5.0 and noticed that my legend is now missing. Anyone else have this problem??

I keep receiving the following error:

o is undefined in dojo.js line 73

This error occurs when

chart1.render(); //Graph shows but error causes the rest of the code in that javascript function to not execute (So, not legend because it's created after chart1.render(); line.

executes. Works perfect in release 1.4.3.


Solution

  • Found the problem..It seems like a bug but not 100% sure...Here is how to recreate it using the Dojo Nightly Charting Tests code and dojo version 1.5.0 (Any web browser):

    NOTE: This error occurs when adding a series to plot "other" and calling chart1.render(); more than once. If chart1.render(); is only called once, no error and everything works as it should. See addSeries for "Series B"...Remove plot: "other" from "Series B" and everything works OK even if chart1.render() is called twice. This problem can also be recreated by just removing "markers: true" from the "default" addPlot and calling char1.render(); twice.

    Warning: The HTML below in the code section isn't displaying 100% correctly but all the javascript code is present to recreate this problem easily.

    Eugene: Thanks for the link to the testing page, that helped out. Also, should I file a bug report on this??

    
        
    
    
    
    
    Event 2D
    
     @import "dojo-release-1.5.0/dojo/resources/dojo.css";
     @import "dojo-release-1.5.0/dijit/tests/css/dijitTests.css";
    
    
    
    
    .dojoxLegendNode {border: 1px solid #ccc; margin: 5px 10px 5px 10px; padding: 3px}
    .dojoxLegendText {vertical-align: text-top; padding-right: 10px}
    
    
    
    
    dojo.require("dojox.charting.Chart2D");
    dojo.require("dojox.charting.themes.PlotKit.green");
    
    dojo.require("dojox.charting.action2d.Highlight");
    dojo.require("dojox.charting.action2d.Magnify");
    dojo.require("dojox.charting.action2d.MoveSlice");
    dojo.require("dojox.charting.action2d.Shake");
    dojo.require("dojox.charting.action2d.Tooltip");
    
    dojo.require("dojox.charting.widget.Legend");
    
    dojo.require("dojo.colors");
    dojo.require("dojo.fx.easing");
    
    var dc = dojox.charting;
    
    var dur = 450;
    var chart1;
    
    makeObjects = function(){
     chart1 = new dc.Chart2D("test1");
     //chart1.setTheme(dc.themes.PlotKit.green);
     chart1.addPlot("default", {type: "Default", lines: true, markers: true, tension:2});
            chart1.addPlot("other",  {type: "Lines",
        hAxis: "other x",
        vAxis: "other y"
       });
     chart1.addPlot("grid",  {type: "Grid",
                 hMajorLines: true,
               hMinorLines: false,
               vMajorLines: true,
               vMinorLines: false
       });
     chart1.addAxis("x", {min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
     chart1.addAxis("y", {vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
     chart1.addAxis("other x", {leftBottom: false, min: 0, max: 6, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
     chart1.addAxis("other y", {leftBottom: false, vertical: true, min: 0, max: 10, majorTick: {stroke: "black", length: 3}, minorTick: {stroke: "gray", length: 3}});
     chart1.addSeries("Series A", [{x: 0.5, y: 5}, {x: 1.5, y: 1.5}, {x: 2, y: 9}, {x: 5, y: 0.3}]);
     chart1.addSeries("Series B", [{x: 0.3, y: 8}, {x: 4, y: 6, tooltip: "Custom tooltip"}, {x: 5.5, y: 2}], {plot: "other"});
     var anim1a = new dc.action2d.Magnify(chart1, "default");
     var anim1b = new dc.action2d.Tooltip(chart1, "default");
     chart1.render();
     chart1.render();
     var legend1 = new dojox.charting.widget.Legend({chart: chart1, horizontal: false}, "legend1");
    
    };
    
    dojo.addOnLoad(makeObjects);
    
    
    
    
    

    Event 2D

    Go

    -->

    Hover over markers, bars, columns, slices, and so on.

    1: Markers, lines, 2D data, custom axis. Actions: Magnify, Tooltip.

    That's all Folks!