-
Notifications
You must be signed in to change notification settings - Fork 58
/
StackedBarChartFragment.kt
96 lines (87 loc) · 4.66 KB
/
StackedBarChartFragment.kt
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
90
91
92
93
94
95
96
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2021. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// StackedBarChartFragment.kt is part of SCICHART®, High Performance Scientific Charts
// For full terms and conditions of the license, see http://www.scichart.com/scichart-eula/
//
// This source code is protected by international copyright law. Unauthorized
// reproduction, reverse-engineering, or distribution of all or any portion of
// this source code is strictly prohibited.
//
// This source code contains confidential and proprietary trade secrets of
// SciChart Ltd., and should at no time be copied, transferred, sold,
// distributed or made available without express written permission.
//******************************************************************************
package com.scichart.examples.fragments.examples2d.multiChart.kt
import android.view.animation.DecelerateInterpolator
import com.scichart.charting.visuals.SciChartSurface
import com.scichart.charting.visuals.axes.AxisAlignment.Bottom
import com.scichart.charting.visuals.axes.AxisAlignment.Left
import com.scichart.examples.fragments.base.ExampleSingleChartBaseFragment
import com.scichart.examples.utils.Constant
import com.scichart.examples.utils.interpolator.DefaultInterpolator
import com.scichart.examples.utils.scichartExtensions.*
class StackedBarChartFragment: ExampleSingleChartBaseFragment() {
override fun initExample(surface: SciChartSurface) {
surface.suspendUpdates {
xAxes { numericAxis { axisAlignment = Left } }
yAxes { numericAxis { axisAlignment = Bottom; flipCoordinates = true} }
renderableSeries {
verticallyStackedColumnsCollection {
stackedColumnRenderableSeries {
xyDataSeries<Double, Double>("Data 1") {
for (i in yValues1.indices) append(i.toDouble(), yValues1[i])
}
dataPointWidth = 0.8
fillBrushStyle = LinearGradientBrushStyle(0xff567893, 0xff3D5568)
strokeStyle = SolidPenStyle(0xff567893, 0f)
waveAnimation {
duration = Constant.ANIMATION_DURATION
startDelay = Constant.ANIMATION_START_DELAY
interpolator = DefaultInterpolator.getInterpolator()
}
}
stackedColumnRenderableSeries {
xyDataSeries<Double, Double>("Data 2") {
for (i in yValues2.indices) append(i.toDouble(), yValues2[i])
}
dataPointWidth = 0.8
fillBrushStyle = LinearGradientBrushStyle(0xffACBCCA, 0xff439AAF)
strokeStyle = SolidPenStyle(0xffACBCCA, 0f)
waveAnimation {
duration = Constant.ANIMATION_DURATION
startDelay = Constant.ANIMATION_START_DELAY
interpolator = DefaultInterpolator.getInterpolator()
}
}
stackedColumnRenderableSeries {
xyDataSeries<Double, Double>("Data 3") {
for (i in yValues3.indices) append(i.toDouble(), yValues3[i])
}
dataPointWidth = 0.8
fillBrushStyle = LinearGradientBrushStyle(0xffDBE0E1, 0xffB6C1C3)
strokeStyle = SolidPenStyle(0xffDBE0E1, 0f)
waveAnimation {
duration = Constant.ANIMATION_DURATION
startDelay = Constant.ANIMATION_START_DELAY
interpolator = DefaultInterpolator.getInterpolator()
}
}
}
}
chartModifiers {
cursorModifier()
zoomExtentsModifier()
}
}
}
companion object {
var yValues1 = doubleArrayOf(0.0, 0.1, 0.2, 0.4, 0.8, 1.1, 1.5, 2.4, 4.6, 8.1, 11.7, 14.4, 16.0, 13.7, 10.1, 6.4, 3.5, 2.5, 5.4, 6.4, 7.1, 8.0, 9.0)
var yValues2 = doubleArrayOf(2.0, 10.1, 10.2, 10.4, 10.8, 1.1, 11.5, 3.4, 4.6, 0.1, 1.7, 14.4, 16.0, 13.7, 10.1, 6.4, 3.5, 2.5, 1.4, 0.4, 10.1, 0.0, 0.0)
var yValues3 = doubleArrayOf(20.0, 4.1, 4.2, 10.4, 10.8, 1.1, 11.5, 3.4, 4.6, 5.1, 5.7, 14.4, 16.0, 13.7, 10.1, 6.4, 3.5, 2.5, 1.4, 10.4, 8.1, 10.0, 15.0)
}
}