Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#4877 closed defect (wontfix)

dojox.charting, data set with only one data point doesn't plot

Reported by: guest Owned by: Eugene Lazutkin
Priority: high Milestone: 1.0
Component: Charting Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

I'd like to use the bar chart as a simple linear gauge sort of control. Basically, I should be able to specify a max value and have just one bar plot against that max value. However, if you specify only one data point in the data for the series, the plot doesn't render.

To reproduce my problem, change the chart for test14 in test_chart2d.html to this:

	var chart14 = new dojox.charting.Chart2D("test14");
	chart14.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});
	chart14.addPlot("default", {type: "Columns", gap: 2});
	chart14.addSeries("Series A", [5], {stroke: {color: "red"}, fill: "lightpink"});
	chart14.render();

Note that I simply removed the second series and changed the data set for "Series A" to have just one data point.

It appears that in renderers.js, collectSimpleStats() looks for a min and max value from the series data. If you only have one data point, though, the min and the max will be the same and so your range for the scaler is effectively 0 which causes nothing to render.

I don't have a good fix, however, if I take this edge case into account at the end of collectSimpleStats() ( if(stats.vmax == stats.vmin) {stats.vmin = 0;} ), I then get a proper render for my one data point.

I should mention that I think a similar problem happens for a line chart as well, though I haven't verified it as thoroughly as I have for the bar (column in this case I guess) chart.

If you have any questions, you can e-mail me at cching at mqsoftware dot com, I couldn't figure out how to create my own trac id, so I just used guest.

Change History (5)

comment:1 in reply to:  description Changed 12 years ago by guest

Sorry, I should have put this under the Charting component, could someone do that for me? Thanks!

comment:2 Changed 12 years ago by tk

Component: GeneralCharting
Owner: changed from anonymous to Tom Trenka

comment:3 Changed 12 years ago by guest

I should note that I asked on the forums about manually setting the max and eugene replied that he'd added this ability last night. Testing today, if you specify a min/max manually on the axes, this is no longer a problem. Maybe that's the solution?

comment:4 Changed 12 years ago by Tom Trenka

Owner: changed from Tom Trenka to Eugene Lazutkin

Eugene, can you confirm?

comment:5 Changed 12 years ago by Eugene Lazutkin

Milestone: 1.0
Resolution: wontfix
Status: newclosed

I can confirm, but there is no way to derive a statistics from a single point. You should specify min and max manually --- see Chart 21 in test_chart2d.html for details.

Note: See TracTickets for help on using tickets.