Skip to content

Commit 7d64a00

Browse files
committed
horizontal legend view fixes, and values shown in percentage for pie and stack charts on touch
1 parent e141bee commit 7d64a00

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

dr-charts/Classes/HorizontalStackChart/HorizontalStackBarChart.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
156156
touchedLayer = shapeLayer;
157157

158158
NSString *data = [shapeLayer valueForKey:@"data"];
159-
[self showMarkerWithData:data withTouchedPoint:touchPoint];
159+
NSString *dataPercentage = [NSString stringWithFormat:@"%0.2f%%",(data.floatValue/totalCount)*100];
160+
[self showMarkerWithData:dataPercentage withTouchedPoint:touchPoint];
160161
if ([self.delegate respondsToSelector:@selector(didTapOnHorizontalStackBarChartWithValue:)]) {
161162
[self.delegate didTapOnHorizontalStackBarChartWithValue:data];
162163
}

dr-charts/Classes/Legend/LegendView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ - (void)createLegend{
6464

6565
if (width >= WIDTH(self)) {
6666
height = height + LEGEND_VIEW + INNER_PADDING;
67-
width = 0;
67+
width += LEGEND_VIEW + size.width + 2*INNER_PADDING;
6868
x = 0;
6969
}
7070

@@ -128,7 +128,7 @@ + (CGFloat)getLegendHeightWithLegendArray:(NSMutableArray *)legendArray legendTy
128128

129129
if (width >= viewWidth) {
130130
height = height + LEGEND_VIEW + INNER_PADDING;
131-
width = 0;
131+
width += LEGEND_VIEW + size.width + 2*INNER_PADDING;
132132
x = 0;
133133
}
134134
}

dr-charts/Classes/PieChart/PieChart.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
160160
touchedLayer = shapeLayer;
161161

162162
NSString *data = [shapeLayer valueForKey:@"data"];
163-
[self showMarkerWithData:data withTouchedPoint:touchPoint];
163+
NSString *dataPercentage = [NSString stringWithFormat:@"%0.2f%%",(data.floatValue/self.totalCount.floatValue)*100];
164+
[self showMarkerWithData:dataPercentage withTouchedPoint:touchPoint];
164165
if ([self.delegate respondsToSelector:@selector(didTapOnPieChartWithValue:)]) {
165166
[self.delegate didTapOnPieChartWithValue:data];
166167
}

0 commit comments

Comments
 (0)