Repository navigation
Expand file tree
/
Copy pathBubbleChart.js
More file actions
174 lines (148 loc) · 5.38 KB
/
Copy pathBubbleChart.js
File metadata and controls
174 lines (148 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/// <reference path="JsChart-vsdoc.js" />
var Charting = MindFusion.Charting;
var Controls = Charting.Controls;
var Collections = MindFusion.Common.Collections;
var Drawing = MindFusion.Drawing;
var chartEl = document.getElementById('chart');
chartEl.width = chartEl.offsetParent.clientWidth;
chartEl.height = chartEl.offsetParent.clientHeight;
var chart = new Controls.BubbleChart(chartEl);
// bubble chart requires three dimensional data;
// two dimensions for position and one for size
var series3D1 = new Charting.PointSeries3D(
new Collections.List
([
new Charting.Point3D(0.32, 81, 95),
new Charting.Point3D(0.39, 66, 78),
new Charting.Point3D(0.75, 65, 76),
new Charting.Point3D(0.49, 60, 71)
]),
new Collections.List(["Germany", "France", "UK", "Italy"]));
series3D1.title = "High Population Regions";
var series3D2 = new Charting.PointSeries3D(
new Collections.List
([
new Charting.Point3D(-0.28, 46, 54),
new Charting.Point3D(-0.32, 42, 50),
new Charting.Point3D(0.05, 38, 45),
new Charting.Point3D(-0.4, 19, 23)
]),
new Collections.List(["Spain", "Ukraine", "Poland", "Romania"]));
series3D2.title = "Standard Population Regions";
var data = new Collections.ObservableCollection();
data.add(series3D1);
data.add(series3D2);
chart.series = data;
// axis titles and ranges
chart.xAxis.title = "Annual Growth Rate (%)";
chart.xAxis.minValue = -1;
chart.xAxis.maxValue = 1;
chart.yAxis.title = "Projected Population (Millions)";
chart.yAxis.minValue = 0;
chart.yAxis.maxValue = 100;
// modern theme settings
chart.showZoomWidgets = true;
chart.gridType = Charting.GridType.Vertical;
chart.backColor = new Drawing.Color("#ffffff");
chart.theme.gridColor1 = new Drawing.Color("#ffffff");
chart.theme.gridColor2 = new Drawing.Color("#fafafa");
chart.theme.gridLineColor = new Drawing.Color("#eceff1");
chart.theme.axisStroke = new Drawing.Brush("#455a64");
chart.theme.axisLabelsBrush = new Drawing.Brush("#455a64");
chart.theme.legendBackground = new Drawing.Brush("#ffffff");
chart.theme.legendBorderStroke = new Drawing.Brush("#eeeeee");
chart.chartPanel.margin = new Charting.Margins(10, 10, 10, 10);
// series colors
chart.theme.commonSeriesFills = new Collections.List([
new Drawing.Brush("rgba(38, 166, 154, 0.7)"), // Teal
new Drawing.Brush("rgba(63, 81, 181, 0.7)") // Indigo
]);
chart.theme.commonSeriesStrokes = new Collections.List([
new Drawing.Brush("#26a69a"),
new Drawing.Brush("#3f51b5")
]);
chart.theme.commonSeriesStrokeThicknesses = new Collections.List([1, 1]);
chart.theme.highlightStroke = new Drawing.Brush("#ffa000");
chart.theme.dataLabelsBrush = new Drawing.Brush("#37474f");
chart.theme.highlightStrokeDashStyle = Drawing.DashStyle.Solid;
chart.draw();
//handlers
(document.getElementById('chbShowScatter')).addEventListener("change", function()
{
chart.showScatter = !chart.showScatter;
});
var chbShowDataLabels = document.getElementById('chbShowDataLabels');
chbShowDataLabels.addEventListener("change", function()
{
chart.showDataLabels = chbShowDataLabels.checked ? Charting.LabelKinds.All : Charting.LabelKinds.None;
chart.invalidate();
});
(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('chbShowZoomWidgets')).addEventListener("change", function()
{
chart.showZoomWidgets = !chart.showZoomWidgets;
});
var cbGridType = document.getElementById('cbGridType');
cbGridType.addEventListener("change", function()
{
chart.gridType = cbGridType.selectedIndex;
});
(document.getElementById('chbPinGrid')).addEventListener("change", function()
{
chart.pinGrid = !chart.pinGrid;
});
(document.getElementById('chbAllowPan')).addEventListener("change", function()
{
chart.allowPan = !chart.allowPan;
});
(document.getElementById('chbAllowMoveLegend')).addEventListener("change", function()
{
chart.allowMoveLegend = !chart.allowMoveLegend;
});
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();
});
(document.getElementById('chbShowLegend')).addEventListener("change", function()
{
chart.showLegend = !chart.showLegend;
});