javascript - Set view finder in nvd3 line chart to specific time on x scale -
i can't figure out how initialize view finder in nvd3 linewithfocuschart exmaple last 3 days. have timestamp stored in 'data'. chart looks fine, don't know how set focus on specific time (example. have data 1 year period , @ last month @ page load). trying add brushextent without results.
function drawlinechart(id, data, width, height){ var ch = nv.addgraph(function() { var chart = nv.models.linewithfocuschart() .width(width) .height(height) .x(function(d){return d.x}) .y(function(d){return d.y}); data = [ { key: "waga", values: [] } ]; for(var i=0; i<data.data.trackers[0].measurements.length; i++){ // parse data fit line chart structure data[0].values.push({x: data.data.trackers[0].measurements[i].date, y: parsefloat(data.data.trackers[0].measurements[i].value)}); } chart.xaxis.tickformat(function(d) { return d3.time.format('%x')(new date(d * 1000)) }); chart.x2axis.tickformat(function(d) { return d3.time.format('%x')(new date(d * 1000)); }); chart.yaxis .tickformat(d3.format(',.2f')); chart.y2axis .tickformat(d3.format(',.2f')); d3.select("#"+id+" svg") .datum(data) .call(chart); nv.utils.windowresize(chart.update); return chart; }); }
Comments
Post a Comment