-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcharts_demo1.html
411 lines (395 loc) · 19.8 KB
/
charts_demo1.html
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<html>
<head>
<title>highcharts报表示例-www.jbxue.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="jquery-2.0.0.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
/**
* highcharts数据图表
*
* @param {object} chart 图表的相关参数配置
* @param {object} credits 图表版权信息参数配置
* @param {object} lang 图表语言参数配置
* @param {object} exporting 导出配置
* @param {object} title 标题配置
* @param {object} xAxis X轴配置
* @param {object} yAxis Y轴配置
* @param {object} plotOptions 各类型图表绘制配置
* @param {object} labels 数据图表标签配置
* @param {array} series 数据源配置
*/
chart = new Highcharts.Chart({
/**
* 图表配置
*
* @param {string} renderTo 图表加载的位置
* @param {int} width 图表的宽度
* @param {int} hight 图表的高度
* @param {string} type 图表的默认类型
* @param {string} zoomType 图表的缩放选项,有:x, y, xy
*/
chart: {
// 图表加载的位置
renderTo: 'container',
// 图表宽度
width: 600,
// 图表高度
hight: 500,
// 默认图表类型
type: 'line',
// 缩放配置:x,y,xy
zoomType: ''
},
/**
* 版权信息配置,不用修改直接复制
*
* @param {boolean} enabled 是否显示版权信息
* @param {string} href 版权信息所链接到的地址
* @param {string} text 版权信息所显示的文字内容
*/
credits:{
enabled: false,
href: "http://www.jbxue.com/Admin",
text: '脚本学堂'
},
/**
* 语言配置,不用修改直接复制
*
* @param {string} exportButtonTitle 导出按钮的标题文字
* @param {string} printButtonTitle 打印按钮的标题文字
*/
lang:{
exportButtonTitle:'导出PDF',
printButtonTitle:'打印报表'
},
/**
* 导出配置,不用修改直接复制
*
* @param {boolean} enabled 是否允许导出
* @param {object} buttons 关于与导出和打印按钮相关的配置对象
* @param {string} filename 导出文件的文件名
* @param {string} type 默认导出文件的格式
*/
exporting:{
// 是否允许导出
enabled:true,
// 按钮配置
buttons:{
// 导出按钮配置
exportButton:{
menuItems: null,
onclick: function() {
this.exportChart();
}
},
// 打印按钮配置
printButton:{
enabled:false
}
},
// 文件名
filename: '报表',
// 导出文件默认类型
type:'application/pdf'
},
/**
* 图表的标题
*
* @param {string} text 图表的标题,如果不需要显示标题,直接设置为空字符串就行
*/
title: {
text: '联合图表实例'
},
/**
* X轴配置
*
* @param {array} categories X轴坐标分类值
* @param {object} labels 坐标标签配置对象
* @param {int} tickInterval 坐标轴的步进值
* @param {object} title 坐标轴标题
*/
xAxis: {
// X轴分类
categories: ['苹果', '桔子', '梨子', '香蕉', '李子'],
// 坐标轴的标签
labels:{
// 标签位置
align: 'center',
// 标签格式化
formatter: function(){
return this.value;
},
// 标签旋转度数
//rotation: 20,
// 标签交错显示的行数
staggerLines: 1
},
// X轴的步进值,决定隔多少个显示一个
tickInterval: 1,
// 坐标轴标题
title: {
text: '水果分类'
}
},
/**
* y轴配置
*
* @param {object} labels 坐标标签配置对象
* @param {int} tickInterval 坐标轴的步进值
* @param {object} title 坐标轴标题
*/
yAxis: {
// 坐标轴的标签
labels:{
// 标签位置
align: 'right',
// 标签格式化
formatter: function(){
return this.value + '个';
}
},
// y轴的步进值,决定隔多少个显示一个
tickInterval: 4,
// 坐标轴标题
title: {
text: '水果个数'
}
},
/**
* 绘图的各选项、参数配置
* @param {object} series 数列,可以配置各种不同类型图表的默认参数
* @param {object} bar 横向柱状图配置参数
* @param {object} column 纵向柱状图配置参数
* @param {object} line 线性图
* @param {object} spline 圆滑曲线图配置参数
* @param {object} pie 饼状图
*/
plotOptions:{
/**
* 数列,对于所有的图表都可以适用的配置参数,属于共用性质。
*/
series: {
// 鼠标样式
cursor: 'pointer',
events:{
// 数据标注不可点击
legendItemClick: false
},
// 当是柱状图时,柱状的宽度
pointWidth: 5
},
/**
* 横向柱状图
*/
bar:{
// 数据点的点击事件
events:{
click: function(event){
//alert('The bar was clicked, and you can add any other functions.');
}
},
// 当值为0时,在图表中柱状体的长度设置
minPointLength: 2,
// 当具体的数据点被点击时的事件响应函数。如果不需要事件响应,可以删除。
point:{
events:{
click: function(){
alert('This point was clicked. You can and any other functions.');
}
}
},
// 是否在图注中显示。
showInLegend: true,
// 是否堆叠,默认:null,数值:normal,百分比:percent
//stacking: 'normal',
// 调整图像顺序关系
zIndex: 1
},
/**
* 纵向柱状图
*/
column:{
// 数据点的点击事件
events:{
click: function(event){
alert('The bar was clicked, and you can add any other functions.');
}
},
// 当值为0时,在图表中柱状体的长度设置
minPointLength: 2,
// 当具体的数据点被点击时的事件响应函数。如果不需要事件响应,可以删除。
point:{
events:{
click: function(){
alert('This point was clicked. You can and any other functions.');
}
}
},
// 是否在图注中显示。
showInLegend: true,
// 是否堆叠,默认:null,数值:normal,百分比:percent
//stacking: null,
// 调整图像顺序关系
zIndex: 2
},
/**
* 线性图,与spline的区别在于点与点之间的连线是直线还是圆滑曲线。
*/
line:{
// 允许线性图上的数据点进行点击
allowPointSelect: true,
// 数据点的点击事件
events:{
click: function(event){
//alert('The bar was clicked, and you can add any other functions.');
}
},
// 当具体的数据点被点击时的事件响应函数。如果不需要事件响应,可以删除。
point:{
events:{
click: function(){
//alert('This point on the line was clicked. You can and any other functions.');
}
}
},
// 是否在图注中显示。
showInLegend: true,
// 调整图像顺序关系
zIndex: 3
},
/**
* 曲线图,与spline的区别在于点与点之间的连线是直线还是圆滑曲线。
*/
spline:{
// 允许线性图上的数据点进行点击
allowPointSelect: true,
// 数据点的点击事件
events:{
click: function(event){
alert('The bar was clicked, and you can add any other functions.');
}
},
// 当具体的数据点被点击时的事件响应函数。如果不需要事件响应,可以删除。
point:{
events:{
click: function(){
//alert('This point on the line was clicked. You can and any other functions.');
}
}
},
// 是否在图注中显示。
showInLegend: true,
// 调整图像顺序关系
zIndex: 3
},
/**
* 饼状图
*/
pie:{
// 是否允许扇区点击
allowPointSelect: true,
// 点击后,滑开的距离
slicedOffset: 5,
// 饼图的中心坐标
center: [50, 80],
// 饼图的大小
size: 100,
// 数据标签
dataLabels: {
// 是否允许标签
enabled: true,
// 标签与图像元素之间的间距
distance: 10
},
// 数据点的点击事件
events:{
click: function(event){
//alert('The bar was clicked, and you can add any other functions.');
}
},
// 是否忽略隐藏的项
ignoreHiddenPoint: true,
// 当具体的数据点被点击时的事件响应函数。如果不需要事件响应,可以删除。
point:{
events:{
click: function(){
//alert('This point on the line was clicked. You can and any other functions.');
}
}
},
// 是否在图注中显示。
showInLegend: false,
// 调整图像顺序关系
zIndex: 0
}
},
/**
* 数据图表标签配置
*
* @param {array} items 项目配置
*/
labels: {
items: [{
html: '水果总消耗量',
style: {
left: '65px',
top: '8px',
color: 'black'
}
}]
},
/**
* 数据源配置,本身是一个对象数组
*
* @param {string} type 图表的类型
* @param {string} name 数据序列的名称
* @param {array} data 数据序列,是一个对象数组
*/
series: [{
type: 'column',
name: 'Jane',
data: [3, 2, 1, 3, 4]
}, {
type: 'column',
name: 'John',
data: [2, 3, 5, 7, 6]
}, {
type: 'column',
name: 'Joe',
data: [4, 3, 3, 9, 0]
}, {
type: 'spline',
name: '平均',
data: [3, 2.67, 3, 6.33, 3.33]
}, {
type: 'pie',
name: '水果总消耗量',
data: [{
name: 'Jane',
y: 13,
color: '#4572A7' // Jane's color
}, {
name: 'John',
y: 23,
color: '#AA4643' // John's color
}, {
name: 'Joe',
y: 19,
color: '#89A54E' // Joe's color
}]
}]
});
});
});
</script>
</head>
<body>
<script src="Highcharts/js/highcharts.js"></script>
<script src="Highcharts/js/themes/dark-green.js"></script>
<script src="Highcharts/js/modules/exporting.js"></script>
<div id="container"></div>
</body>
</html>