FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript-Chart-Samples/src/Tutorial1.js at master · MindFusionComponents/JavaScript-Chart-Samples · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
MindFusionComponents
/
JavaScript-Chart-Samples
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript-Chart-Samples
/
src
/
Tutorial1.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
336 lines (275 loc) · 11.3 KB
Breadcrumbs
JavaScript-Chart-Samples
/
src
/
Tutorial1.js
Copy path
File metadata and controls
336 lines (275 loc) · 11.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/// <reference path="JsChart-vsdoc.js" />
var
Charting
=
MindFusion
.
Charting
;
var
Components
=
Charting
.
Components
;
var
Controls
=
Charting
.
Controls
;
var
Collections
=
MindFusion
.
Common
.
Collections
;
var
Drawing
=
MindFusion
.
Drawing
;
// 1. Dashboard Container Setup
var
dashboardEl
=
document
.
getElementById
(
'dashboard'
)
;
dashboardEl
.
width
=
dashboardEl
.
offsetParent
.
clientWidth
;
dashboardEl
.
height
=
dashboardEl
.
offsetParent
.
clientHeight
;
var
dashboard
=
new
Controls
.
ChartBase
(
dashboardEl
)
;
var
builder
=
new
Controls
.
LayoutBuilder
(
dashboard
)
;
// styling settings for the dashboard
dashboard
.
theme
.
plotBackground
=
new
Drawing
.
Brush
(
"#FFFFFF"
)
;
dashboard
.
theme
.
gridLineColor
=
new
Drawing
.
Color
(
"#F1F5F9"
)
;
// header and title
var
tc
=
new
Components
.
TextComponent
(
)
;
tc
.
text
=
"SALES & DISTRIBUTION OVERVIEW"
;
tc
.
fontName
=
"sans-serif"
;
tc
.
fontStyle
=
Drawing
.
FontStyle
.
Bold
;
tc
.
fontSize
=
16
;
tc
.
textBrush
=
new
Drawing
.
Brush
(
"#0F172A"
)
;
tc
.
horizontalAlignment
=
Components
.
LayoutAlignment
.
Center
;
dashboard
.
layoutPanel
.
children
.
add
(
tc
)
;
var
grid
=
new
Components
.
GridPanel
(
)
;
// define line and bar plots
var
linePlot
=
new
Charting
.
Plot2D
(
)
;
linePlot
.
background
=
new
Drawing
.
Brush
(
"#FFFFFF"
)
;
var
barPlot
=
new
Charting
.
Plot2D
(
)
;
var
radarPlot
=
new
Charting
.
RadarPlot
(
)
;
var
polarPlot
=
new
Charting
.
PolarPlot
(
)
;
var
plot3d1
=
new
Charting
.
Plot3D
(
)
;
var
plot3d2
=
new
Charting
.
Plot3D
(
)
;
var
plot3d3
=
new
Charting
.
Plot3D
(
)
;
var
plot4
=
new
Charting
.
Plot2D
(
)
;
// define the axes
linePlot
.
xAxis
=
new
Charting
.
Axis
(
)
;
linePlot
.
xAxis
.
minValue
=
0
;
linePlot
.
xAxis
.
maxValue
=
15
;
linePlot
.
xAxis
.
interval
=
1
;
linePlot
.
xAxis
.
title
=
"Period"
;
linePlot
.
yAxis
=
new
Charting
.
Axis
(
)
;
linePlot
.
yAxis
.
minValue
=
0
;
linePlot
.
yAxis
.
maxValue
=
35
;
linePlot
.
yAxis
.
interval
=
5
;
linePlot
.
yAxis
.
title
=
"Volume (k)"
;
// the grid is crossed
linePlot
.
gridType
=
Charting
.
GridType
.
Crossed
;
//styling the grid
linePlot
.
gridLineColor
=
Drawing
.
Color
(
"#E2E8F0"
)
;
linePlot
.
gridLineStyle
=
Drawing
.
DashStyle
.
Dash
;
// Options: Solid, Dash, Dot, Custom
linePlot
.
gridLineWidth
=
1
;
//set alternating grid stripes
linePlot
.
gridColor1
=
Drawing
.
Color
(
"#FFFFFF"
)
;
linePlot
.
gridColor2
=
Drawing
.
Color
(
"#cecece"
)
;
barPlot
.
xAxis
=
new
Charting
.
Axis
(
)
;
barPlot
.
xAxis
.
minValue
=
-
1
;
barPlot
.
xAxis
.
maxValue
=
15
;
barPlot
.
xAxis
.
interval
=
3
;
barPlot
.
xAxis
.
title
=
"Period"
;
barPlot
.
yAxis
=
new
Charting
.
Axis
(
)
;
barPlot
.
yAxis
.
minValue
=
0
;
barPlot
.
yAxis
.
maxValue
=
35
;
barPlot
.
yAxis
.
interval
=
5
;
barPlot
.
yAxis
.
title
=
"Volume (k)"
;
// set horizontal grid for the bar chart
barPlot
.
gridType
=
Charting
.
GridType
.
Horizontal
;
// define the grid appearance
barPlot
.
gridLineColor
=
Drawing
.
Color
(
"#E2E8F0"
)
;
barPlot
.
gridLineStyle
=
Drawing
.
DashStyle
.
Dash
;
// Options: Solid, Dash, Dot, Custom
barPlot
.
gridLineWidth
=
1
;
// set alternating grid stripes for the bar grid
barPlot
.
gridColor1
=
Drawing
.
Color
(
"#FFFFFF"
)
;
barPlot
.
gridColor2
=
Drawing
.
Color
(
"#F8FAFC"
)
;
// define data series
var
dataValues
=
[
10
,
15
,
17
,
16
,
20
,
15
,
14
,
13
,
10
,
17
,
22
,
25
,
25
,
25
,
21
,
21
]
;
var
labelsList
=
[
]
;
var
currentDate
=
new
Date
(
)
;
var
baseMonth
=
currentDate
.
getMonth
(
)
-
1
;
var
currentYear
=
currentDate
.
getFullYear
(
)
;
if
(
baseMonth
<
0
)
{
baseMonth
+=
12
;
currentYear
-=
1
;
}
var
monthNames
=
[
"jan"
,
"feb"
,
"mar"
,
"apr"
,
"may"
,
"jun"
,
"jul"
,
"aug"
,
"sep"
,
"oct"
,
"nov"
,
"dec"
]
;
for
(
var
i
=
dataValues
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
targetMonthIndex
=
baseMonth
-
i
;
var
targetYear
=
currentYear
;
while
(
targetMonthIndex
<
0
)
{
targetMonthIndex
+=
12
;
targetYear
-=
1
;
}
labelsList
.
push
(
monthNames
[
targetMonthIndex
]
+
"\n"
+
targetYear
)
;
}
var
data1
=
new
Charting
.
BarSeries
(
new
Collections
.
List
(
dataValues
)
,
null
,
null
,
new
Collections
.
List
(
labelsList
)
)
;
data1
.
title
=
"Berlin"
;
var
data2
=
new
Charting
.
BarSeries
(
new
Collections
.
List
(
[
13
,
13
,
14
,
16
,
23
,
25
,
20
,
19
,
16
,
17
,
15
,
13
,
13
,
17
,
18
,
21
]
)
,
null
)
;
data2
.
title
=
"Paris"
;
var
data3
=
new
Charting
.
BarSeries
(
new
Collections
.
List
(
[
29
,
28
,
29
,
31
,
33
,
35
,
33
,
27
,
28
,
28
,
27
,
29
,
29
,
31
,
33
,
29
]
)
,
null
)
;
data3
.
title
=
"Rome"
;
//create the necessary series renderers
var
lineRenderer
=
new
Charting
.
LineRenderer
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
barDataRenderer
=
new
Charting
.
BarRenderer
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
radarDataRenderer
=
new
Charting
.
RadarRenderer
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
pieDataRenderer
=
new
Charting
.
PieRenderer
(
data1
,
1
)
;
var
bar3DDataRenderer
=
new
Charting
.
BarRenderer3D
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
horizontalBar3DDataRenderer
=
new
Charting
.
BarRenderer
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
barStack3DRenderer
=
new
Charting
.
BarStackRenderer3D
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
var
barOverlay3DRenderer
=
new
Charting
.
BarOverlayRenderer3D
(
new
Collections
.
ObservableCollection
(
[
data1
,
data2
,
data3
]
)
)
;
// set the colours
var
fillsList
=
new
Collections
.
List
(
[
new
Drawing
.
Brush
(
Drawing
.
Color
.
fromArgb
(
0.75
,
14
,
165
,
233
)
)
,
// Sky Blue
new
Drawing
.
Brush
(
Drawing
.
Color
.
fromArgb
(
0.75
,
99
,
102
,
241
)
)
,
// Indigo
new
Drawing
.
Brush
(
Drawing
.
Color
.
fromArgb
(
0.75
,
16
,
185
,
129
)
)
// Emerald
]
)
;
var
strokesList
=
new
Collections
.
List
(
[
new
Drawing
.
Brush
(
"#0284C7"
)
,
new
Drawing
.
Brush
(
"#4F46E5"
)
,
new
Drawing
.
Brush
(
"#059669"
)
]
)
;
lineRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
2
,
2
,
2
]
)
)
;
barDataRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
)
;
bar3DDataRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
1
]
)
)
;
horizontalBar3DDataRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
1
]
)
)
;
horizontalBar3DDataRenderer
.
horizontalBars
=
true
;
barOverlay3DRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
1
]
)
)
;
barStack3DRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
1
]
)
)
;
radarDataRenderer
.
seriesStyle
=
new
Charting
.
PerSeriesStyle
(
fillsList
,
strokesList
,
new
Collections
.
List
(
[
2
]
)
)
;
radarDataRenderer
.
areaOpacity
=
0.25
;
radarPlot
.
defaultAxis
.
minValue
=
0
;
radarPlot
.
defaultAxis
.
maxValue
=
35
;
radarPlot
.
defaultAxis
.
interval
=
5
;
radarPlot
.
axisOptions
=
new
Charting
.
RadarAxisOptions
(
radarPlot
.
defaultAxis
)
;
radarPlot
.
axisOptions
.
showSeriesLabels
=
true
;
radarPlot
.
axisOptions
.
axisStroke
=
new
Drawing
.
Brush
(
"#CBD5E1"
)
;
radarPlot
.
defaultAxis
.
title
=
""
;
// assign each renderer to its corresponding plot
linePlot
.
seriesRenderers
.
add
(
lineRenderer
)
;
barPlot
.
seriesRenderers
.
add
(
barDataRenderer
)
;
radarPlot
.
seriesRenderers
.
add
(
radarDataRenderer
)
;
polarPlot
.
seriesRenderers
.
add
(
pieDataRenderer
)
;
plot3d1
.
seriesRenderers
.
add
(
bar3DDataRenderer
)
;
plot3d2
.
seriesRenderers
.
add
(
barStack3DRenderer
)
;
plot3d3
.
seriesRenderers
.
add
(
barOverlay3DRenderer
)
;
plot4
.
seriesRenderers
.
add
(
horizontalBar3DDataRenderer
)
;
// setup for the 3D plot and axes
plot3d1
.
xAxis
=
new
Charting
.
Axis
(
)
;
plot3d1
.
xAxis
.
minValue
=
0
;
plot3d1
.
xAxis
.
maxValue
=
5
;
plot3d1
.
xAxis
.
interval
=
1
;
plot3d1
.
xAxis
.
title
=
"Months"
;
plot3d1
.
yAxis
=
new
Charting
.
Axis
(
)
;
plot3d1
.
yAxis
.
minValue
=
0
;
plot3d1
.
yAxis
.
maxValue
=
40
;
plot3d1
.
yAxis
.
interval
=
5
;
plot3d1
.
yAxis
.
title
=
"Thousands"
;
plot3d2
.
xAxis
=
plot3d3
.
xAxis
=
plot3d1
.
xAxis
;
plot3d2
.
yAxis
=
plot3d3
.
yAxis
=
plot3d1
.
yAxis
;
plot3d2
.
yAxis
=
new
Charting
.
Axis
(
)
;
plot3d2
.
yAxis
.
minValue
=
0
;
plot3d2
.
yAxis
.
maxValue
=
100
;
plot3d2
.
yAxis
.
interval
=
20
;
plot3d2
.
yAxis
.
title
=
"Thousands"
;
plot4
.
yAxis
=
new
Charting
.
Axis
(
)
;
plot4
.
yAxis
.
minValue
=
0
;
plot4
.
yAxis
.
maxValue
=
4
;
plot4
.
yAxis
.
interval
=
1
;
plot4
.
yAxis
.
title
=
"Months"
;
plot4
.
xAxis
=
new
Charting
.
Axis
(
)
;
plot4
.
xAxis
.
minValue
=
0
;
plot4
.
xAxis
.
maxValue
=
40
;
plot4
.
xAxis
.
interval
=
10
;
plot4
.
xAxis
.
title
=
"Thousands"
;
plot4
.
verticalScroll
=
true
;
// a helper function for styling the exis of a renderer
function
applyAxisStyles
(
renderer
)
{
renderer
.
axisStroke
=
new
Drawing
.
Brush
(
"#CBD5E1"
)
;
renderer
.
axisStrokeThickness
=
1
;
renderer
.
titleBrush
=
new
Drawing
.
Brush
(
"#334155"
)
;
renderer
.
titleFontName
=
"sans-serif"
;
renderer
.
titleFontSize
=
10
;
renderer
.
titleFontStyle
=
Drawing
.
FontStyle
.
Bold
;
renderer
.
labelBrush
=
new
Drawing
.
Brush
(
"#64748B"
)
;
renderer
.
labelFontName
=
"sans-serif"
;
renderer
.
labelFontSize
=
9
;
}
//axes renderers for the fourth plot
var
xAxisRenderer
=
new
Charting
.
XAxisRenderer
(
plot4
.
xAxis
)
;
applyAxisStyles
(
xAxisRenderer
)
;
var
yAxisRenderer
=
new
Charting
.
YAxisRenderer
(
plot4
.
yAxis
)
;
applyAxisStyles
(
yAxisRenderer
)
;
// axes renderers for the line plot panel
var
xar
=
new
Charting
.
XAxisRenderer
(
linePlot
.
xAxis
)
;
applyAxisStyles
(
xar
)
;
xar
.
labelsSource
=
linePlot
;
xar
.
showCoordinates
=
false
;
xar
.
labelRotationAngle
=
15
;
var
yar1
=
new
Charting
.
YAxisRenderer
(
linePlot
.
yAxis
)
;
applyAxisStyles
(
yar1
)
;
var
panel1
=
builder
.
createPlotWithBottomAndLeftAxes
(
linePlot
,
xar
,
yar1
)
;
// axes renderers for the bar plot panel
xar
=
new
Charting
.
XAxisRenderer
(
barPlot
.
xAxis
)
;
applyAxisStyles
(
xar
)
;
xar
.
labelsSource
=
linePlot
;
xar
.
showCoordinates
=
false
;
xar
.
labelRotationAngle
=
15
;
var
yar2
=
new
Charting
.
YAxisRenderer
(
barPlot
.
yAxis
)
;
applyAxisStyles
(
yar2
)
;
var
panel2
=
builder
.
createPlotWithBottomAndRightAxes
(
barPlot
,
xar
,
yar2
)
;
// axes renderers for the 3D bar plot
xar
=
new
Charting
.
XAxisRenderer
(
plot3d1
.
xAxis
)
;
applyAxisStyles
(
xar
)
;
xar
.
showCoordinates
=
false
;
var
yar3
=
new
Charting
.
YAxisRenderer
(
plot3d1
.
yAxis
)
;
applyAxisStyles
(
yar3
)
;
var
panel3
=
builder
.
createPlotWithTopAndRightAxes
(
plot3d1
,
xar
,
yar3
)
;
// axes renderers for other 3D plot
xar
=
new
Charting
.
XAxisRenderer
(
plot3d2
.
xAxis
)
;
applyAxisStyles
(
xar
)
;
var
yar4
=
new
Charting
.
YAxisRenderer
(
plot3d2
.
yAxis
)
;
applyAxisStyles
(
yar4
)
;
var
panel4
=
builder
.
createPlotWithTopAndLeftAxes
(
plot3d2
,
xar
,
yar4
)
;
// axes renderers for the third 3D plot
xar
=
new
Charting
.
XAxisRenderer
(
plot3d3
.
xAxis
)
;
applyAxisStyles
(
xar
)
;
var
yar5
=
new
Charting
.
YAxisRenderer
(
plot3d3
.
yAxis
)
;
applyAxisStyles
(
yar5
)
;
var
panel5
=
builder
.
createPlotWithTopAndRightAxes
(
plot3d3
,
xar
,
yar5
)
;
//create the plot for the horizontal bar chart
var
panel6
=
builder
.
createPlotWithTopAndLeftAxes
(
plot4
,
xAxisRenderer
,
yAxisRenderer
)
;
panel1
.
margin
=
panel2
.
margin
=
panel3
.
margin
=
panel4
.
margin
=
panel5
.
margin
=
panel6
.
margin
=
new
Charting
.
Margins
(
6
,
6
,
6
,
6
)
;
// customize the grids
grid
.
columns
.
add
(
new
Components
.
GridColumn
(
)
)
;
grid
.
rows
.
add
(
new
Components
.
GridRow
(
)
)
;
var
miniGrid
=
new
Components
.
GridPanel
(
)
;
miniGrid
.
columns
.
add
(
new
Components
.
GridColumn
(
)
)
;
miniGrid
.
rows
.
add
(
new
Components
.
GridRow
(
)
)
;
panel1
.
gridColumn
=
0
;
panel1
.
gridRow
=
0
;
panel2
.
gridColumn
=
1
;
panel2
.
gridRow
=
0
;
radarPlot
.
gridColumn
=
0
;
radarPlot
.
gridRow
=
1
;
polarPlot
.
gridColumn
=
0
;
polarPlot
.
gridRow
=
0
;
panel3
.
gridColumn
=
1
;
panel3
.
gridRow
=
0
;
panel4
.
gridColumn
=
0
;
panel4
.
gridRow
=
1
;
panel5
.
gridColumn
=
1
;
panel5
.
gridRow
=
1
;
panel6
.
gridColumn
=
0
;
panel6
.
gridRow
=
0
;
// setup for the legend
var
legend
=
new
Charting
.
LegendRenderer
(
)
;
legend
.
content
.
add
(
lineRenderer
)
;
legend
.
showTitle
=
false
;
grid
.
children
.
add
(
panel1
)
;
grid
.
children
.
add
(
panel2
)
;
grid
.
children
.
add
(
radarPlot
)
;
grid
.
children
.
add
(
miniGrid
)
;
miniGrid
.
children
.
add
(
panel3
)
;
miniGrid
.
children
.
add
(
panel4
)
;
miniGrid
.
children
.
add
(
panel5
)
;
miniGrid
.
children
.
add
(
panel6
)
;
miniGrid
.
gridColumn
=
1
;
miniGrid
.
gridRow
=
1
;
dashboard
.
layoutPanel
.
children
.
add
(
grid
)
;
dashboard
.
rootPanel
.
children
.
add
(
legend
)
;
dashboard
.
draw
(
)
;
Back
|
FazBrowse Home
|
New Git URL