javascript - Using slider on combined bar and linechart -
i build chart combining bar-chart , line-chart in d3.js , added slider updates x-axis not chart itself. attempts failed far. found nice example kind of similar: http://bl.ocks.org/dem42/3878029
i made fiddle, check out here: http://jsfiddle.net/karolinka/zpy0pqlu/10/ thinking in advance. code within slider function:
x.domain(d3.range(minv, maxv + 1)); xaxis.tickformat(function(i) { return times[i]; }); svg.transition().duration(750) .select(".x.axis").call(xaxis); linescalex.domain(d3.range(minv, maxv + 1)); svg.transition().duration(750) .select(".lines").attr("d", line);
in case anyones interested: line interpolation not nice, works now: http://jsfiddle.net/karolinka/zpy0pqlu/40/. in end hid additional elements jquery this:
if(newtimes.length<5){ $(".bars:nth-child(5)").hide(); } else { $(".bars:nth-child(5)").show(); }``
not best way guess if remove old elements , append them again, i´m not getting smooth transition.
Comments
Post a Comment