Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update candle chart view options in demo project #3424

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ChartsDemo-iOS/Objective-C/Demos/CandleStickChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ - (void)viewDidLoad
@{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"},
@{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"},
@{@"key": @"toggleShadowColorSameAsCandle", @"label": @"Toggle shadow same color"},
@{@"key": @"toggleShowCandleBar", @"label": @"Toggle show candle bar"},
@{@"key": @"toggleData", @"label": @"Toggle Data"},
];

Expand Down Expand Up @@ -132,6 +133,15 @@ - (void)optionTapped:(NSString *)key
set.shadowColorSameAsCandle = !set.shadowColorSameAsCandle;
}

[_chartView notifyDataSetChanged];
return;
} else if ([key isEqualToString:@"toggleShowCandleBar"])
{
for (id<ICandleChartDataSet> set in _chartView.data.dataSets)
{
set.showCandleBar = !set.showCandleBar;
}

[_chartView notifyDataSetChanged];
return;
}
Expand Down
2 changes: 2 additions & 0 deletions ChartsDemo-iOS/Swift/DemoBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum Option {
case toggleBarBorders
// CandleChart
case toggleShadowColorSameAsCandle
case toggleShowCandleBar
// CombinedChart
case toggleLineValues
case toggleBarValues
Expand Down Expand Up @@ -60,6 +61,7 @@ enum Option {
case .toggleBarBorders: return "Toggle Bar Borders"
// CandleChart
case .toggleShadowColorSameAsCandle: return "Toggle shadow same color"
case .toggleShowCandleBar: return "Toggle show candle bar"
// CombinedChart
case .toggleLineValues: return "Toggle Line Values"
case .toggleBarValues: return "Toggle Bar Values"
Expand Down
11 changes: 9 additions & 2 deletions ChartsDemo-iOS/Swift/Demos/CandleStickChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CandleStickChartViewController: DemoBaseViewController {
.togglePinchZoom,
.toggleAutoScaleMinMax,
.toggleShadowColorSameAsCandle,
.toggleShowCandleBar,
.toggleData]

chartView.delegate = self
Expand Down Expand Up @@ -103,12 +104,18 @@ class CandleStickChartViewController: DemoBaseViewController {
}

override func optionTapped(_ option: Option) {
if .toggleShadowColorSameAsCandle ~= option {
switch option {
case .toggleShadowColorSameAsCandle:
for set in chartView.data!.dataSets as! [CandleChartDataSet] {
set.shadowColorSameAsCandle = !set.shadowColorSameAsCandle
}
chartView.notifyDataSetChanged()
} else {
case .toggleShowCandleBar:
for set in chartView.data!.dataSets as! [CandleChartDataSet] {
set.showCandleBar = !set.showCandleBar
}
chartView.notifyDataSetChanged()
default:
super.handleOption(option, forChartView: chartView)
}
}
Expand Down