-
Notifications
You must be signed in to change notification settings - Fork 20
/
ErrorBarsChartView.m
executable file
·89 lines (73 loc) · 4.31 KB
/
ErrorBarsChartView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// ErrorBarsChartView.m is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied.
//******************************************************************************
#import "ErrorBarsChartView.h"
#import "SCDDataManager.h"
@implementation ErrorBarsChartView
- (void)initExample {
SCIHlDataSeries *dataSeries0 = [[SCIHlDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
SCIHlDataSeries *dataSeries1 = [[SCIHlDataSeries alloc] initWithXType:SCIDataType_Double yType:SCIDataType_Double];
SCDDoubleSeries *data = [SCDDataManager getFourierSeriesWithAmplitude:1.0 phaseShift:0.1 xStart:5.0 xEnd:5.15 count:5000];
[self fillSeries:dataSeries0 sourceData:data scale:1.0];
[self fillSeries:dataSeries1 sourceData:data scale:1.3];
uint color = 0xFFC6E6FF;
SCIFastErrorBarsRenderableSeries *errorBars0 = [SCIFastErrorBarsRenderableSeries new];
errorBars0.dataSeries = dataSeries0;
errorBars0.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:color thickness:1.f];
errorBars0.errorDirection = SCIErrorDirection_Vertical;
errorBars0.errorType = SCIErrorType_Absolute;
SCIEllipsePointMarker *pMarker = [SCIEllipsePointMarker new];
pMarker.size = CGSizeMake(5, 5);
pMarker.fillStyle = [[SCISolidBrushStyle alloc] initWithColorCode:color];
SCIFastLineRenderableSeries *lineSeries = [SCIFastLineRenderableSeries new];
lineSeries.dataSeries = dataSeries0;
lineSeries.pointMarker = pMarker;
lineSeries.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:color thickness:1.f];
SCIFastErrorBarsRenderableSeries *errorBars1 = [SCIFastErrorBarsRenderableSeries new];
errorBars1.dataSeries = dataSeries1;
errorBars1.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:color thickness:1.f];
errorBars1.errorDirection = SCIErrorDirection_Vertical;
errorBars1.errorType = SCIErrorType_Absolute;
SCIEllipsePointMarker *sMarker = [SCIEllipsePointMarker new];
sMarker.size = CGSizeMake(7, 7);
sMarker.fillStyle = [[SCISolidBrushStyle alloc] initWithColorCode:0x00FFFFFF];
sMarker.strokeStyle = [[SCISolidPenStyle alloc] initWithColorCode:color thickness:1];
SCIXyScatterRenderableSeries *scatterSeries = [SCIXyScatterRenderableSeries new];
scatterSeries.dataSeries = dataSeries1;
scatterSeries.pointMarker = sMarker;
[SCIUpdateSuspender usingWithSuspendable:self.surface withBlock:^{
[self.surface.xAxes add:[SCINumericAxis new]];
[self.surface.yAxes add:[SCINumericAxis new]];
[self.surface.renderableSeries addAll:lineSeries, scatterSeries, errorBars0, errorBars1, nil];
[self.surface.chartModifiers add:ExampleViewBase.createDefaultModifiers];
[SCIAnimations scaleSeries:lineSeries duration:3.0 andEasingFunction:[SCIElasticEase new]];
[SCIAnimations scaleSeries:scatterSeries duration:3.0 andEasingFunction:[SCIElasticEase new]];
[SCIAnimations scaleSeries:errorBars0 duration:3.0 andEasingFunction:[SCIElasticEase new]];
[SCIAnimations scaleSeries:errorBars1 duration:3.0 andEasingFunction:[SCIElasticEase new]];
}];
}
- (void)fillSeries:(id<ISCIHlDataSeries>)dataSeries sourceData:(SCDDoubleSeries *)sourceData scale:(double)scale {
SCIDoubleValues *xValues = sourceData.xValues;
SCIDoubleValues *yValues = sourceData.yValues;
SCIDoubleValues *highValues = [SCIDoubleValues new];
SCIDoubleValues *lowValues = [SCIDoubleValues new];
for (int i = 0 ; i < yValues.count; i++) {
[yValues set:[yValues getValueAt:i] * scale at:i];
[highValues add:randf(0.0, 1.0) * 0.2];
[lowValues add:randf(0.0, 1.0) * 0.2];
}
[dataSeries appendValuesX:xValues y:yValues high:highValues low:lowValues];
}
@end