Opened 13 years ago

Last modified 12 years ago

#8868 closed defect

Bug in default assignment of colors to chart series — at Initial Version

Reported by: petraRock Owned by: Eugene Lazutkin
Priority: high Milestone: 1.5
Component: Charting Version: 1.2.3
Keywords: Cc:
Blocked By: Blocking:


Automatic assignment of colors from the theme to chart series works fine for addSeries( ) and updateSeries( ) except when a series contains an empty data array. If a series has an empty data array, then it seems to be skipped in the color allocation from the theme. Then if that series is later updated with data via an updateSeries( ), the colors are reassigned from the theme and to the user the colors switch on the graph from one series to the other.

(I use this technique of updateSeries(name, []) to simulate hiding a series on a line graph and then use updateSeries(name, [data]) to show the series again. To work around this problem, I have to leave a single data point in the "empty" data array in order to have the colors not switch when I hide/show the series.)

The following small sample illustrates this bug.


<style type="text/css">

@import "../../../dojo/resources/dojo.css"; @import "../../../dijit/tests/css/dijitTests.css";

</style> <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script> <script type="text/javascript">

dojo.require("dojox.charting.Chart2D"); dojo.require("dojox.charting.themes.Shrooms");

var makeObjects = function() {

var c = new dojox.charting.Chart2D("test"); c.addPlot("default", {type: "Lines"}); c.addAxis("x", {fixUpper: "major", fixLower:"minor"}); c.addAxis("y", {vertical: true, fixUpper: "major", includeZero: true}); c.setTheme(dojox.charting.themes.Shrooms); c.addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4]); c.addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]); cData = [2, 2.2, 2, 2.2, 2, 2.2, 2]; c.addSeries("Series C", []); c.render(); alert("Series A and B have data...C is empty"); c.updateSeries("Series C", cData); alert("Series C has now been updated with data. Refresh when you click OK"); c.render(); alert("Notice that C now got B's color, B got A's color, and A got a new color. The theme rotates colors.");




</head> <body> <div id="test" style="width: 400px; height: 400px;"></div>


Change History (0)

Note: See TracTickets for help on using tickets.