-
Notifications
You must be signed in to change notification settings - Fork 605
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
Can not create Dygraph object with null or empty data #597
Comments
I don't want to support You can get an empty chart by plotting a CSV file with no data, e.g. new Dygraph(document.getElementById("graph"), "X\n", {}); |
If you're set on using native format, you could also do something like: g = new Dygraph('graph', [[0]], {labels:['X']}); I could be more easily convinced that |
We don't have the labels, neither we know how many series there will be when creating the Dygraph object. For me it doesn't make sense to construct Dygraph with temporary data and labels. Can we perhaps agree on the below being a valid code then? :-) g = new Dygraph('graph', [], {labels:[]}); |
So, what's is the solution to set graph's data after it's been returned by the server? |
@markzolotoy you just do |
+1 for this request - right now my solution would be to create a graph with a single point, which I will remove the first time real data is added. Quite some lines of code for no real reason. ['NaN', 'NaN'] seems like a predestinated point to solve this issue, however drawing the graph doesn't work if this is the first entry. |
+1 for this request. Empty array makes more sense than null. Thanks, |
I just have my data points set to [[startX],[endX]] value and it shows the graph with the X Range specified where I want to show. |
I'd like this feature, too. Seems that |
could really use [] as initialization parameter. Kindly add support for it.. |
+1 for g = new Dygraph('graph', [], {labels:[]}); |
new Dygraph(document.getElementById("graph"), "X\n", {}); I used the above . but why does it show a "11:00" as the x axis start value. How can i get a blank graph may be start with 0 on X tx |
What if I want to redraw the the dygraph plot, is there a way to do so? When I obtain new data from the server, I want the existing plot to be cleared and redrawn with the new data. I currently use the follwing method updateOptions( { 'file': data } ); but all it does is to add the new data to the previous data and displays both on the plot. |
@angrybirdnut |
@danvk : Thanks, i took another look at my JS code and it turns out the issue was actually with my code (an array I was using was incorrectly concatenating all new data coming in from the server with the existing data). I have resolved it and g.updateOptions({file: newData}) is working well as intended. |
It's 2019 and an empty array throws an error :-\ There should be support for a graph with no data since the data could be provided at a later time. I'm pretty sure people have forked this library simply to remove this check. Is this library being maintained? |
See #727. I'm not actively working on dygraphs and have no plans to resume doing so. If anyone is interested in taking ownership, I'm happy to share the commit bit. As for this issue itself, I'd be fine with |
Ok, I'll implement showing an empty plot when |
How to create data set for multiple series? I have multiple labels and need an empty set to be initialized |
+1 for the same. |
Currently I use this hack - var flag = 50; //the number of empty/0/null data points you are forced to initialize
if (flag>0){
flag-=1;
data.shift();
data.push([x, y, z, w]);
}
else{
data.push([x, y, z, w]);
} |
But the above doesn't work well because of the timestamp issue. As the initial points are plotted based on time that is calculated at the start of the script, when a certain amount of time passes before your dynamic data starts coming in, there is a very ugly stretch of the plot at the beginning. I don't know how to avoid that. |
I’ve implemented the |
@mirabilos I'm currently encountering the same issue. It appears that the changes have not yet been released to npm in the version |
@kaihenzler no, it’s in 2.2.1, the requested |
Thanks for the quick response :) The fixed line from the commit mentioned above is not in the dist/dygraph.js file that is published on npm Commit: c888d4c |
That’s because it was later moved. |
I created a minimal example that shows that the error still appears in the browser console for version 2.2.1 https://stackblitz.com/edit/vitejs-vite-kqbgxg?file=main.js
Could you please check again if something went wrong when publishing 2.2.1 or could you maybe release the next alpha version so this fix is available in npm? |
In stackblitz it cannot be debugged. But I patched the The problem is not the data, incidentally, as can easily, directly and immediately be seen in the F12 console, it’s the labels.
So just omit the labels (or the entire options object) for this. You’ll have to provide them together with the data when the amount of columns in the data changes, anyway. Sorry, I could have tested that, but as I’m actually using the “don’t pass any data at first” thing in a project, I knew it worked. |
It would be nice if we could create Dygraph object without passing in any data (null) or alternatively empty array ([]).
This would allow us to create the Dygraph object first and pass data to it only when we receive them from server etc.
I ended up modifying the start_ function and added the following check
if (data == null) {
return;
}
I also tried passing in empty array but that logs an error:
"Can't plot empty data set"
The text was updated successfully, but these errors were encountered: