subchart: Initial zoom and pan

1,095 views
Skip to first unread message

sonof...@gmail.com

unread,
Jul 31, 2014, 4:11:26 PM7/31/14
to c3...@googlegroups.com
Hi,

I have a timeseries chart navigable with a subchart, and I want it to start showing only the last week (and in general, programmatically modify zoom and pan but not by modifying axis range which would affect subchart as well).

Reading c3.js, I don't see any way in which `brush` is exposed, and even if it were - I wouldn't know where to begin implementing this.

1) Is it possible?

2) If I add a feature request, will you make it possible?

Thanks!
Aur

Vivek Ranjan

unread,
Aug 23, 2014, 2:36:36 PM8/23/14
to c3...@googlegroups.com
Hi Aur,

Did you find any solution for this?

Thanks,
Vivek

fili...@gmail.com

unread,
Sep 26, 2014, 1:15:47 PM9/26/14
to c3...@googlegroups.com
Hi guys,
I managed to access the brush of the chart as chart.internal.brush.
Since it is "internal" I assume it is not intended to be used as api, but it helped me achieve what I needed.

Here is an important example to look at:
https://github.com/masayuki0812/c3/blob/master/htdocs/samples/axes_x_extent.html
You can set the x.axis.extent property when you call c3.generate. Note that it can be a array of Date objects, not just strings.

Then I used the following to remember the "last brush extent". Note that this refers to my widget which the .lastBrushExtent property is hanged onto.

chart.internal.brush.on("brush", $.proxy({self: this, "do": function () {
chart.internal.redrawForBrush(); // apply the brush
this.self.lastBrushExtent = chart.internal.brush.extent(); // remember last extent
}}, "do"));

When I generate a new chart I set .axis.x.extent = this.lastBrushExtent.

This is probably not the full answer to the original question, but it gives you some indication where to start with this.
Filip.

Reply all
Reply to author
Forward
0 new messages