javascript - How to highlight particular region in horizontal way in dygraph and how to create dynamic graph -
i need highlight y value example 20 -10 , -30 -45 in y axis. permanently color opacity 50%, how do., in example how add external csv file following code. pls guide me
var orig_range; window.onload = function(){ var r = []; var arr = ["7/13/2015 0:15:45",45,"7/13/2015 0:30",5,"7/13/2015 0:45",100,"7/13/2015 1:00",95,"7/13/2015 1:15",88,"7/13/2015 1:30",78]; (var = 0; < arr.length; i++) { r.push([ new date(arr[i]),arr[i+1] ]); i++; } orig_range = [ r[0][0].valueof(), r[r.length - 1][0].valueof() ]; g2 = new dygraph( document.getelementbyid("div_g"), r, { rollperiod: 7, animatedzooms: true, // errorbars: true, width: 1000, height: 500, xlabel: 'date', ylabel: 'pressure', } ); var desired_range = null;}; function approach_range() { if (!desired_range) return; // go halfway there var range = g2.xaxisrange(); if (math.abs(desired_range[0] - range[0]) < 60 && math.abs(desired_range[1] - range[1]) < 60) { g2.updateoptions({datewindow: desired_range}); // (do not set timeout.) } else { var new_range; new_range = [0.5 * (desired_range[0] + range[0]), 0.5 * (desired_range[1] + range[1])]; g2.updateoptions({datewindow: new_range}); animate(); } } function animate() { settimeout(approach_range, 50); } function zoom(res) { var w = g2.xaxisrange(); desired_range = [ w[0], w[0] + res * 1000 ]; animate(); } function reset() { desired_range = orig_range; animate(); } function pan(dir) { var w = g2.xaxisrange(); var scale = w[1] - w[0]; var amount = scale * 0.25 * dir; desired_range = [ w[0] + amount, w[1] + amount ]; animate(); }
<script src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/1.1.0/dygraph-combined-dev.js"></script> <div id="div_g"></div> <div id="output"></div> <b>zoom:</b> <a href="#" onclick="zoom(3600)">hour</a> <a href="#" onclick="zoom(86400)">day</a> <a href="#" onclick="zoom(604800)">week</a> <a href="#" onclick="zoom(30 * 86400)">month</a> <a href="#" onclick="reset()">full</a> <b>pan:</b> <a href="#" onclick="pan(-1)">left</a> <a href="#" onclick="pan(+1)">right</a>
var data = ["te1.csv"]; g2 = new dygraph(document.getelementbyid("div_g"), data, { drawpoints: true, showroller: true, labels:['date','depth'], }); setinterval(function() { data.push([data]); g2.updateoptions( { 'file': data } ); }, 1000);
i have seen example dont know how link csv file dynamic dygraph pls guide me
this example extremely similar want: highlights specific range on x-axis. adapt it, you'd this:
new dygraph(data, div, { underlaycallback: function (canvas, area, g) { var bottom = g.todomycoord(highlight_start); var top = g.todomycoord(highlight_end); canvas.fillstyle = "rgba(255, 255, 102, 1.0)"; canvas.fillrect(area.x, top, area.w, bottom - top); } })
Comments
Post a Comment