FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

Line chart only showing the first label when only one data point is provided #432

Closed xingped closed 8 years ago

xingped commented 8 years ago

It is possible to show multiple labels on a line chart when those labels don't have data points. An example of how I use this - showing the progression of data over a week. I can have labels for every day of the week but only have data points so far for Sunday and Monday or something like that.

However, even if there's multiple labels, if there's only one data point, the chart doesn't draw the other labels. This can be verified using the livegap chart generator with a line chart and simply deleting all the data points (keep the labels) except the first data point for each data series.

Expected behavior: All the labels should still be shown regardless if there is one or multiple data points.

markosko commented 8 years ago

not sure what u have as data but for me this works


var mydata1 = {
    labels : ["January","February","March","April","May","June","July"],
    datasets : [
        {
            fillColor : "rgba(220,220,220,0.5)",
            strokeColor : "rgba(220,220,220,1)",
            pointColor : "rgba(220,220,220,1)",
            pointstrokeColor : "yellow",
            data : [16,,,,,,],

      title : "2014"
        }
    ]
}               

image

FVANCOP commented 8 years ago

Hi,

As explained by Markoc, yes it is possible; Check following link https://github.com/FVANCOP/ChartNew.js/wiki/150_Missing_Values

@omarsedki : I've seen that there is a bug in livegap. If in the provided data, you simply remove the data for month February (but the label "February" remains), on the chart, the data for March will be associated to February... The generated data is "data[65,90,81,56,55,40,"] instead of "data[65,,90,81,56,55,40,]".

Regards, François

xingped commented 8 years ago

That was it, thanks @FVANCOP