ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.52k stars 5.99k forks source link

Draw Horiztontal Line on Bar Chart #976

Closed mrxprt closed 8 years ago

mrxprt commented 8 years ago

Hi ,

it's not an issue . am just wandering if i can draw a line horizontally on Bar Chart like that in image

confluence page_threshold line3

thanks

dxclancy commented 8 years ago

It's a good idea to check the ChartDemo for questions like these. For instance, if you look at the LineChart1ViewContoller, you'll see that it has limit lines, which I think will accomplish what you want. Here's a snippet from the Demo that might help.

    ChartLimitLine *ll1 = [[ChartLimitLine alloc] initWithLimit:130.0 label:@"Upper Limit"];
    ll1.lineWidth = 4.0;
    ll1.lineDashLengths = @[@5.f, @5.f];
    ll1.labelPosition = ChartLimitLabelPositionRightTop;
    ll1.valueFont = [UIFont systemFontOfSize:10.0];

    ChartLimitLine *ll2 = [[ChartLimitLine alloc] initWithLimit:-30.0 label:@"Lower Limit"];
    ll2.lineWidth = 4.0;
    ll2.lineDashLengths = @[@5.f, @5.f];
    ll2.labelPosition = ChartLimitLabelPositionRightBottom;
    ll2.valueFont = [UIFont systemFontOfSize:10.0];

    ChartYAxis *leftAxis = _chartView.leftAxis;
    [leftAxis removeAllLimitLines];
    [leftAxis addLimitLine:ll1];
    [leftAxis addLimitLine:ll2];
liuxuan30 commented 8 years ago

yep, it's either limitline or guide line, both supported.

mrxprt commented 8 years ago

Extremely thank full , you are right i have to check the Demos but i was building a POC with a very Limited time , really you saved my day 👍