Repository navigation
Expand file tree
/
Copy pathBarChart3D.js
More file actions
157 lines (123 loc) · 5.38 KB
/
Copy pathBarChart3D.js
File metadata and controls
157 lines (123 loc) · 5.38 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
var Charting = MindFusion.Charting;
var Controls = Charting.Controls;
var Collections = MindFusion.Common.Collections;
var Drawing = MindFusion.Drawing;
var chartEl = document.getElementById('chart');
var chart = new Controls.BarChart3D(chartEl, Charting.BarLayout.SideBySide);
var bgImage;
chart.title = "Agricultural Produce by Type";
// the sample data
var labels = new Collections.List(["Tomatoes", "Cucumbers", "Peppers", "Lettuce"]);
var collection = new Collections.ObservableCollection();
var series = new Charting.Series2D(new Collections.List([10, 20, 30, 40]), new Collections.List([50, 40, 50, 5]), labels);
series.title = "Traditional";
collection.add(series);
series = new Charting.Series2D(new Collections.List([10, 20, 30, 40]), new Collections.List([60, 10, 20, 80]), labels);
series.title = "Urban";
collection.add(series);
series = new Charting.Series2D(new Collections.List([10, 20, 30, 40]), new Collections.List([0, 60, 0, 90]), labels);
series.title = "Hydroponics";
collection.add(series);
chart.series = collection;
// initialize brushes and strokes: one per series
chart.theme.commonSeriesFills = new Collections.List([
new Drawing.Brush(new Drawing.Color("#0EA5E9")),
new Drawing.Brush(new Drawing.Color("#6366F1")),
new Drawing.Brush(new Drawing.Color("#10B981"))
]);
chart.theme.commonSeriesStrokes = new Collections.List([
new Drawing.Brush(new Drawing.Color("#0284C7")),
new Drawing.Brush(new Drawing.Color("#4F46E5")),
new Drawing.Brush(new Drawing.Color("#059669"))
]);
chart.theme.commonSeriesStrokeThicknesses = new Collections.List([1, 1, 1]);
// customize the background
chart.backColor = new Drawing.Color("#FFFFFF");
chart.plotImageLocation = bgImage = 'Resources/bgimage.png';
chart.plotImageAlign = Drawing.ImageAlign.MiddleLeft;
chart.plotImageAutoSize = false;
// customize the axes
chart.xAxis.title = "";
chart.yAxis.title = "Quantity in tons";
chart.theme.axisStroke = new Drawing.Brush(new Drawing.Color("#CBD5E1"));
chart.theme.axisLabelsBrush = new Drawing.Brush(new Drawing.Color("#64748B"));
chart.theme.axisTitleBrush = new Drawing.Brush(new Drawing.Color("#334155"));
chart.theme.axisStrokeThickness = 1;
// legend
chart.legendTitle = "Agricultural Type";
chart.theme.legendBackground = new Drawing.Brush(new Drawing.Color("#F8FAFC"));
chart.theme.legendBorderStroke = new Drawing.Brush(new Drawing.Color("#E2E8F0"));
chart.theme.legendBorderStrokeThickness = 1;
chart.theme.legendTitleBrush = new Drawing.Brush(new Drawing.Color("#0F172A"));
chart.legendMargin = new Charting.Margins(80, 5, 5, 5);
// customize the chart labels
chart.theme.dataLabelsBrush = new Drawing.Brush(new Drawing.Color("#0F172A"));
chart.layoutPanel.margin = new Charting.Margins(12, 12, 12, 12);
chart.draw();
// handlers
(document.getElementById('chbShowScatter')).addEventListener("change", function () {
chart.showScatter = !chart.showScatter;
});
(document.getElementById('chbShowXTicks')).addEventListener("change", function () {
chart.showXTicks = !chart.showXTicks;
});
(document.getElementById('chbShowYTicks')).addEventListener("change", function () {
chart.showYTicks = !chart.showYTicks;
});
(document.getElementById('chbShowXCoords')).addEventListener("change", function () {
chart.showXCoordinates = !chart.showXCoordinates;
});
(document.getElementById('chbShowYCoords')).addEventListener("change", function () {
chart.showYCoordinates = !chart.showYCoordinates;
});
(document.getElementById('chbAllowPan')).addEventListener("change", function () {
chart.allowPan = !chart.allowPan;
});
(document.getElementById('chbAllowMoveLegend')).addEventListener("change", function () {
chart.allowMoveLegend = !chart.allowMoveLegend;
});
(document.getElementById('chbAllowZoom')).addEventListener("change", function () {
chart.allowZoom = !chart.allowZoom;
});
(document.getElementById('btnResetZoom')).addEventListener("click", function () {
chart.resetZoom();
});
(document.getElementById('chbShowBackground')).addEventListener("change", function () {
if (chart.plotImageLocation != null)
chart.plotImageLocation = null;
else
chart.plotImageLocation = bgImage;
chart.draw();
});
var cbxBarLayout = document.getElementById('cbxBarLayout');
cbxBarLayout.addEventListener("change", function () {
chart.barLayout = cbxBarLayout.selectedIndex;
});
var cbxBarModel3D = document.getElementById('cbxBarModel3D');
cbxBarModel3D.addEventListener("change", function () {
chart.barModel = cbxBarModel3D.selectedIndex;
});
var cbLegendHorAlign = document.getElementById('cbLegendHorAlign');
cbLegendHorAlign.addEventListener("change", function () {
chart.legendHorizontalAlignment = cbLegendHorAlign.selectedIndex;
});
var cbLegendVerAlign = document.getElementById('cbLegendVerAlign');
cbLegendVerAlign.addEventListener("change", function () {
chart.legendVerticalAlignment = cbLegendVerAlign.selectedIndex;
});
var tbLegendMarginLeft = document.getElementById('tbLegendMarginLeft');
tbLegendMarginLeft.addEventListener("change", function () {
var margin = chart.legendMargin;
margin.left = parseInt(tbLegendMarginLeft.value);
chart.legendMargin = margin;
chart.invalidateLayout(chart.rootPanel);
chart.draw();
});
var tbLegendMarginTop = document.getElementById('tbLegendMarginTop');
tbLegendMarginTop.addEventListener("change", function () {
var margin = chart.legendMargin;
margin.top = parseInt(tbLegendMarginTop.value);
chart.legendMargin = margin;
chart.invalidateLayout(chart.rootPanel);
chart.draw();
});