Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line chart: Empty values are rendered as 0 #46

Closed
meertens opened this issue Jun 30, 2015 · 5 comments
Closed

Line chart: Empty values are rendered as 0 #46

meertens opened this issue Jun 30, 2015 · 5 comments
Assignees

Comments

@meertens
Copy link

We would like empty values in the data points to not show, instead of 0 as a value. This would be a more correct representation of our data (data points with 0 might be correct measurements. empty data points mean the measurement is missing).

The simpleChart widget used to handle it this way.

According to http://stackoverflow.com/questions/30462042/line-chartjs-empty-null-values-doesnt-break-the-line/30478786#30478786 it should be possible with ChartJS.

@Rvthof
Copy link
Contributor

Rvthof commented Jul 1, 2015

Couldn't you filter out these results in the datasource microflow?

These sort of cases is one of the main reasons it uses a microflow as datasource, as opposed to xpath where it's much harder to get around this.

@meertens
Copy link
Author

meertens commented Jul 2, 2015

Thank you for the quick response. Preparing the data with a microflow indeed seems perfect to me.

I've been trying what you suggest, but I can't get it to work the way I would like to.

I'll give two extra examples / details:
A chart of the current day with 24 hours should have the same x-scale/labels as the previous day, but as the data for the upcoming hours is not available, the line should end at the current hour. As shown in this image:
image

When measurements are not available for a certain time, it should be clear that the measurement is missing, rather than a measurement of zero. In the example below, no data was available until day 20 of the month, at which point the minimum and average were both zero. On days 21 and 22 no measurements were available. On days 23 and 24 the measurements are available again.
image

@JelteMX JelteMX closed this as completed Apr 8, 2016
@meertens
Copy link
Author

meertens commented May 17, 2016

In the latest release, I am able to make this work quite easily. However, I have to change some code for it. As this includes the comment "Convert to integer, so the stackedbar doesnt break!", I am afraid that this might break something else though.
Below is the code that makes the empty points work. The last commented line is the original.

var pointvalue = set.points[i].get(this.seriesylabel);
if (pointvalue == "") {
        pointvalue = null;
    }
points.push(pointvalue);
//   points.push(+(set.points[i].get(this.seriesylabel))); // Convert to integer, so the stackedbar doesnt break!```

@JelteMX JelteMX reopened this May 17, 2016
@JelteMX
Copy link
Contributor

JelteMX commented May 17, 2016

@meertens thanks, I'll have a look at it this week

@meertens
Copy link
Author

An improvement that also works with Decimals (that was probably what the comment was for):

                    var pointvalue = set.points[i].get(this.seriesylabel);
                    if (pointvalue == "") {
                        points.push(null);
                    } else {
                        points.push(+pointvalue); // Convert to number, so the stackedbar doesnt break!
                    }

@JelteMX JelteMX self-assigned this May 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants