Skip to content

Commit 2cdd9ee

Browse files
committed
Merge pull request #66 from mkubenka/limit-line-xaxis
Fix x-axis limit line render issue + x-limit-line example
2 parents 933f4b2 + a6baa45 commit 2cdd9ee

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Charts/Classes/Renderers/ChartXAxisRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public class ChartXAxisRenderer: ChartAxisRendererBase
244244

245245
_limitLineSegmentsBuffer[0].x = position.x;
246246
_limitLineSegmentsBuffer[0].y = viewPortHandler.contentTop;
247-
_limitLineSegmentsBuffer[1].x = position.y;
247+
_limitLineSegmentsBuffer[1].x = position.x;
248248
_limitLineSegmentsBuffer[1].y = viewPortHandler.contentBottom;
249249

250250
CGContextSetStrokeColorWithColor(context, l.lineColor.CGColor);

ChartsDemo/Classes/Demos/LineChart1ViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ - (void)viewDidLoad
5757
_chartView.pinchZoomEnabled = YES;
5858
_chartView.highlightIndicatorEnabled = NO;
5959

60+
// x-axis limit line
61+
ChartLimitLine *llXAxis = [[ChartLimitLine alloc] initWithLimit:10.f label:@"Index 10"];
62+
llXAxis.lineWidth = 4.f;
63+
llXAxis.lineDashLengths = @[@(10.f), @(10.f), @(0.f)];
64+
llXAxis.labelPosition = ChartLimitLabelPositionRight;
65+
llXAxis.valueFont = [UIFont systemFontOfSize:10.f];
66+
67+
[_chartView.xAxis addLimitLine:llXAxis];
68+
6069
ChartLimitLine *ll1 = [[ChartLimitLine alloc] initWithLimit:130.f label:@"Upper Limit"];
6170
ll1.lineWidth = 4.f;
6271
ll1.lineDashLengths = @[@5.f, @5.f];

0 commit comments

Comments
 (0)