Jawbone/JBChartView

Bar Origin Above 0

Closed this issue · 1 comments

I have a requirement where I want to draw the bars with dynamic origin points.
For example one bar will start from 1.2 and may be end at 4.2, so the height will be 3.0
Or
One bar starts at 2.3 and ends at 4.9

The point is that I want to have different origin for bars other than 0 which is the defaults implementation.

Is there any way that I can achieve this?
Thanks.

There is no way to do this natively through the library (all bar origins start at 0).

There is however, a workaround that requires a bit of custom work. You'll have to create (custom) UIViews for each bar in the chart supply them via:

- (UIView *)barChartView:(JBBarChartView *)barChartView barViewAtIndex:(NSUInteger)index;

Each bar's background color can be set to clear. You can then draw custom content on the bar (ie. a subview which has an origin > 0).

It's precisely how Jawbone is able to draw it's custom sleep charts (see screenshot).

Hope this helps.

thorpe-new-sleep-graphs