Dygraph - Live data update with vertical zoom - javascript

I have dygrpah live data update which updated data every seconds.
Once i will do the vertical zoom and data will gets refreshed after a second so vertical zoom gets reset again; and chart start updating data as usual.
can any one have idea how to maintain vertical zoom and update the data?
Thanks

Use "valueRange" property.
In "zoomCallback" callback function, you will getting the yRanges. Assign the range to the "valueRange" property. You could something similar to this,
grpah.updateOptions({
valueRange: [zoomMinY, zoomMaxY]
});

Related

d3 chart is showing some decimal value in the X axis tick, instead of showing the date and time

My d3 timeline chart is showing some junk value (decimal) in the x-axis tick, instead of showing the date and time.
This only happens when there is a single data in the graph.
As shown in the diagram below.
code sandbox - https://codesandbox.io/s/exciting-clarke-yfd1e
I found the root cause of this, It is happening because of the initial call on the chart load. I am doing a zoom transform on the chart load. If I remove this line it works as expected but I can't remove as this is required (Initial zoom transform to apply on default chart load - d3.zoomIdentity).
Code creating the issue is below -
var transform = d3.zoomIdentity.translate(200, 0).scale(0.5);
svg.call(zoom.transform, transform); //This is initial call on chart load
Please suggest to me how to fix this issue in the d3 chart.
Thanks in advance.
This seems to be an issue with the scale, so when there is only one data the default behavior is considering it as a date but after transforming it's considered as a number
and the junk value is coming as last 3 digits of the number i.e, in your case
startTime: "1574504520049" is .049
So if you update the scale to somewhere near that you will be able to get time as
d3.zoomIdentity.translate(100, 50).scale(0.0000000001)
Please check https://github.com/d3/d3-zoom/issues/57
it will help you find a proper scale for the problem.

Jquery Graph to display Engine Status

I need to draw a graph to display engine status.That is i will be having time like 1-2,2-3,3-4 along axis and by using bar graph i need to display whether engine was on or off at these time.
That is from 1-2 if it is off it will how black and 2-4 if it is on it will show blue color and again if the status is changed it should show black from blue.Right now i have customised jquery high charts for displaying one bar,by removing some parameters.
I need to know how i implment this here or is it possible in this graph?
You can do this with a column range chart, with minimal fudging.
The main issue is making sure you set your data points correctly, and to set grouping:false in the plotOptions. The x value needs to be specified for each data as well, or else they will all be given a separate x value
Example:
http://jsfiddle.net/jlbriggs/o9ck2zLn/
This can easily be adapted to a time axis by supplying the timestamps as the y values.

Use a jquery type slider to iterate through a csv and display one bar at a time in a d3.js bar chart

So I'm generating bar chart in D3.js with a csv file a la the basic columns example. What I want to do is show just one bar at a time for each row of data. A JQuery-like slider will iterate over the csv rows and update the chart. For the user, it'll just look like the single bar's height is changing but the x axis should update with the date as well.
Here's an example of the data that I'll be feeding into it:
DATE,INFLOW (CF),OUTFLOW (CF),STORAGE (CF)
20120101,950400,28857600,11084277600
20120102,60912000,28771200,11099959200
20120103,56505600,28857600,11130451200
20120104,55900800,28771200,11158765200
20120105,55987200,28771200,11189692800
20120106,56419200,28771200,11220620400
20120107,55123200,28684800,11246756400
The only thing I actually want to show is DATE and STORAGE (CF). So I'll probably have to do some parsing of the CSV somewhere to get it in the best shape.
I've attempted this and would post some code but all of my attempts are a mess. I can generate a plausible bar chart with all of the rows at once, but when I attempt to show a single one, everything breaks. Here are the challenges that I could use some guidance one:
How to splice or filter my csv with a slider so that only a single row is selected
Best way to generate a bar chart that only has a single bar from a single row in a csv (every time I try to do this I have trouble with axes and accessing the array values correctly)
Best way to update the bar, changing only height but also updating the x axis ticks
Also any examples would be very helpful! Have been googling like mad but am mostly finding sliders that affect range and scale
There are many pieces to this...parsing and slicing the data, setting up the x axis, etc. Here is one segment of the code.
d3.select("#slider")
.on("input", function() {update(+this.value);});
function update(row) {
viewdata = data.slice((row-1), row);
redraw();
}
Here is a complete PLUNK with the solution. NOTE: I have placed comments in several parts of the code, for orientation. I strongly suggest you fork this plunk so that it will not be lost if I inadvertently delete it.

How can we change the marker size after zooming in jqplot?

I'm using jqPlot to render a graph with zooming enabled.
See example:
http://jsfiddle.net/gcollect/yGLmT/
In the example above, I have a chart with a markerSize of 5 and I have a working zoom-event detection.
I need the plot to change its markerSize, when zoomed in. and reset it to its default, when zoomed out.
I was thinkingt of a solution, without replotting the graph. Since replotting looses the actual zoom level.
For example:
plot1.replot(options)
would change the markerSize, but looses the zoom level again.
Try updating options value using,
options.seriesDefaults['size'] = 25;
Then reploat/redraw the graph. But re plotting will surely resize the graph.

Animating column chart

I am using Highcharts to create a bar chart, and trying to figure out how to animate the changes that I am making to the chart. I have set animated to true, but its not showing any changes, just redrawing the bar to the new height.
How can I have it animate changes? Right now I am setting the data with series.setData(), not sure if there is a way to set a specific bar, maybe this is why it does not animate?
http://jsfiddle.net/nycynik/FACtf/
var series = this.series[0];
chartData1[Math.floor(Math.random()*10)] = Math.random()*125;
series.setData(chartData1, true);
Series.setData() doesn't animate because all the points are thrown away and replaced with new ones.
What you are looking for is Point.update(). When you run point update you are only updating the value, so the point is able to animate from the old value to the new one.
chart.series[0].data[0].update(Math.random());
See demo.

Categories

Resources