Repository navigation
Expand file tree
/
Copy pathInteractivity.js
More file actions
164 lines (133 loc) · 5.2 KB
/
Copy pathInteractivity.js
File metadata and controls
164 lines (133 loc) · 5.2 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/// <reference path="../Scripts/jspack-vsdoc.js" />
var Charting = MindFusion.Charting;
var Controls = Charting.Controls;
var Collections = MindFusion.Common.Collections;
var Drawing = MindFusion.Drawing;
var Components = Charting.Components;
var barChartEl = document.getElementById('barChart');
barChartEl.width = barChartEl.offsetParent.clientWidth;
barChartEl.height = barChartEl.offsetParent.clientHeight;
// Create the BarChart
var barChart = new Controls.BarChart(barChartEl);
barChart.series = getSeriesCollection();
barChart.allowZoom = true;
barChart.allowPan = true;
barChart.allowMoveLegend = true;
barChart.xAxis.title = "";
barChart.xAxis.minValue = 0;
barChart.xAxis.maxValue = 3;
barChart.yAxis.title = "";
barChart.yAxis.minValue = 0;
barChart.yAxis.maxValue = 100;
barChart.innerLabelRotation = -90;
barChart.showLegendTitle = false;
barChart.showLegend = true;
barChart.legendHorizontalAlignment = Components.LayoutAlignment.Near;
barChart.legendVerticalAlignment = Components.LayoutAlignment.Near;
barChart.theme = new Charting.Theme();
barChart.theme.commonSeriesFills = getBarFills();
barChart.theme.commonSeriesStrokes = getBarStrokes();
barChart.theme.commonSeriesStrokeThicknesses = new Collections.List([1, 1, 1]);
// Legend Styling
barChart.theme.legendBackground = new Drawing.Brush("#818181");
barChart.theme.legendBorderStroke = new Drawing.Brush("#E2E8F0");
barChart.theme.legendTitleBrush = new Drawing.Brush("#0F172A");
// Interactive Highlights & Grid
barChart.theme.highlightStroke = new Drawing.Brush("#F59E0B");
barChart.gridType = Charting.GridType.Horizontal;
barChart.theme.gridColor1 = new Drawing.Color("#FFFFFF");
barChart.theme.gridColor2 = new Drawing.Color("#F8FAFC");
barChart.theme.gridLineColor = new Drawing.Color("#E2E8F0");
// styling the chart
barChart.theme.axisStroke = new Drawing.Brush("#CBD5E1");
barChart.theme.axisLabelsBrush = new Drawing.Brush("#64748B");
barChart.theme.dataLabelsBrush = new Drawing.Brush("#FFFFFF");
// Create the PieChart
var pieChartEl = document.getElementById('pieChart');
pieChartEl.width = pieChartEl.offsetParent.clientWidth * 0.8;
pieChartEl.height = pieChartEl.offsetParent.clientHeight * 0.8;
var pieChart = new Controls.PieChart(pieChartEl);
pieChart.series = new Charting.PieSeries(
new Collections.List([20, 60, 40, 55]),
new Collections.List(["January", "February", "March", "April"]),
new Collections.List(["January", "February", "March", "April"]));
pieChart.series.title = "Pie Series";
pieChart.allowZoom = true;
pieChart.allowRotate = true;
pieChart.showLegend = false;
pieChart.showDataLabels = Charting.LabelKinds.OuterLabel;
pieChart.theme = new Charting.Theme();
pieChart.theme.seriesFills = getPieFills();
pieChart.theme.uniformSeriesStroke = new Drawing.Brush("#FFFFFF");
pieChart.theme.seriesStrokeThicknesses = new Collections.List([new Collections.List([2])]);
pieChart.theme.highlightStroke = new Drawing.Brush("#334155");
pieChart.theme.highlightStrokeThickness = 2;
// labels brush for the pie pieces
pieChart.theme.dataLabelsBrush = new Drawing.Brush("#334155");
function getSeriesCollection() {
var collection = new Collections.ObservableCollection();
for (var i = 0; i < 3; i++) {
if (i == 0) {
var series1 = new Charting.Series2D(new Collections.List([0, 1, 2, 3]),
new Collections.List([20, 60, 40, 55]),
new Collections.List(["January", "February", "March", "April"]));
series1.title = "Series 1";
collection.add(series1);
}
if (i == 1) {
var series2 = new Charting.Series2D(new Collections.List([0, 1, 2, 3]),
new Collections.List([30, 70, 65, 19]),
new Collections.List(["May", "June", "July", "August"]));
series2.title = "Series 2";
collection.add(series2);
}
if (i == 2) {
var series3 = new Charting.Series2D(new Collections.List([0, 1, 2, 3]),
new Collections.List([22, 44, 33, 66]),
new Collections.List(["September", "October", "November", "December"]));
series3.title = "Series 3";
collection.add(series3);
}
collection.item(i).supportedLabels = Charting.LabelKinds.InnerLabel;
}
return collection;
}
function getBarFills() {
var fills = new Collections.List();
fills.add(new Drawing.Brush("#0EA5E9")); // Sky Blue
fills.add(new Drawing.Brush("#6366F1")); // Indigo
fills.add(new Drawing.Brush("#10B981")); // Emerald
return fills;
}
function getBarStrokes() {
var strokes = new Collections.List();
strokes.add(new Drawing.Brush("#0284C7"));
strokes.add(new Drawing.Brush("#4F46E5"));
strokes.add(new Drawing.Brush("#059669"));
return strokes;
}
function getPieFills() {
var fills = new Collections.List();
fills.add(new Collections.List([
new Drawing.Brush("#0EA5E9"), // Sky Blue
new Drawing.Brush("#6366F1"), // Indigo
new Drawing.Brush("#10B981"), // Emerald
new Drawing.Brush("#64748B"), // Slate
]));
return fills;
}
// Handlers
var chart = document.getElementById('chart');
chart.addEventListener("change", function () {
var bardiv = document.getElementById('bar');
var piediv = document.getElementById('pie');
piediv.style.visibility = "visible";
if (chart.selectedIndex == 0) {
bardiv.style.display = "block";
piediv.style.display = "none";
}
else if (chart.selectedIndex == 1) {
bardiv.style.display = "none";
piediv.style.display = "block";
}
});