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

Empty data is causing chart to break #142

Closed
nareshv opened this issue Dec 27, 2012 · 7 comments
Closed

Empty data is causing chart to break #142

nareshv opened this issue Dec 27, 2012 · 7 comments
Milestone

Comments

@nareshv
Copy link

nareshv commented Dec 27, 2012

Very good library. Thanks for creating.

I have faced an issue. For some of the time series data there are no results and its causing the chart not to render anything

Its helpful to show a message (configurable) when the chart is rendered but without any data

See http://jsbin.com/otaxef/35/edit for the problem

This is needed mostly when we are using .setData() function to render the chart from dynamically fetched data from server.

@tiraeth
Copy link
Contributor

tiraeth commented Dec 27, 2012

This is UI-specific and in my opinion should be handled on your end. For instance, you can test .data property of the object created with Morris.Line to see if the data is set correctly and if not - provide a placeholder.

@nareshv
Copy link
Author

nareshv commented Dec 27, 2012

There are few more things here.

Lets take the below timeline of events.

  1. First time Morris.Line is rendered with proper .data via ajax
  2. Second time , When the data object is empty, Chart is completely un-usable
  3. Third time, when we render on the same chart with data via ajax. nothing happens.

Like you have suggested, i can handle it in the UI. Everyone who implements or encounters such situation have to implement this placeholder message by themselves. Instead, if we can handle it in the Library itself then everyone can get benefited from it and library is more defensive.

Lets go with placeholder approach

  1. First time, Morris.Line is rendered with data from ajax
  2. Second time, data is empty. Instead of calling .setData() hide the div element that is rendered/managed by Morris and show a placeholder message using span.
  3. Third time, when data is correct, remove the span and re-render the Morris.Line

I'd recommend to implement this feature within the library itself so that library is more defensive to such runtime problems.

@nareshv
Copy link
Author

nareshv commented Jan 8, 2013

can we provide this solution, it really helps wider audience.

@oesmith
Copy link
Contributor

oesmith commented Jan 25, 2013

There will not be a placeholder by default in morris.js it's up to you to provide a meaningful message to your users that fits the formatting of your site.

However, if there's an issue where an empty data object breaks the chart with setData, then we should fix that.

@nareshv
Copy link
Author

nareshv commented Jan 25, 2013

The idea is to make sure that the library doesn't break when there is empty chart data.

Possible solutions can be either to show a placeholder message or show a empty graph. (or any other solution which makes the library usable after empty dataset is passed to it)

@oesmith oesmith closed this as completed in 811dc87 Feb 6, 2013
@TGM
Copy link

TGM commented Sep 9, 2013

+1 for nareshv sugestion, it's very usefull.

@lallmon
Copy link

lallmon commented Nov 5, 2014

Is there a setting, option or way to just render the empty graph if no data? My use case is a "30 day earnings" line chart, and if there are no earnings, there are no earnings, and it should still reflect that.

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

5 participants