demo.html
3.7 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
<div id="barchart" class="page out" data-title="柱状图插件">
<div id="barchart-header"></div>
<div id="barchart-a"></div>
<div id="barchart-b"></div>
</div>
<script>
require(["NavHeader", "BarChart"], function(NavHeader, BarChart) {
var _u = require("mUtil");
var hasClsPicker = typeof clsPicker !== "undefined";
if(!hasClsPicker) {
new NavHeader({
el: "barchart-header",
option: {
title:"柱状图插件",
smallTitle:"barchart"
}
}).render();
}
new BarChart({
el: "barchart-a",
option: {
dataAxis: "yAxis",//xAxis 横向 yAxis 纵向
data: [
{ "name": "1月", "蒸发量": "2.0", "降水量": "2.6" },
{ "name": "2月", "蒸发量": "4.9", "降水量": "5.9" },
{ "name": "3月", "蒸发量": "7.0", "降水量": "9.0" },
{ "name": "4月", "蒸发量": "23.2", "降水量": "25.6" },
{ "name": "5月", "蒸发量": "25.0", "降水量": "28.7" },
{ "name": "6月", "蒸发量": "2.0", "降水量": "2.6" }
],//图表数据
height: 400,//图表高度
title: {
show: true,
text: "某地区蒸发量和降水量",//标题
subtext: "纯属虚构"//副标题
},
grid: {
top: 80,//上边距
bottom: 60,//底部边距
left: "10%"//左边距
},
legend: {
show: true,//是否显示图例
bottom: 10,//图例底部边距
textStyle: {
color: "#333"//字体颜色
}
},
axisLabel: {
interval: 0,//坐标标签间隔,0表示显示所有坐标
rotate: 0,//坐标标签旋转角度
textStyle: {
fontSize: 12//坐标标签字体大小
}
},
isShowMarkPoint: true,//在最大和最小柱状上显示具体的数值
isShowMarkLine: true,//在图表上显示一根平均值的标线
color: "#c23531,#2f4554,#61a0a8,#d48265,#91c7ae,#749f83,#ca8622,#bda29a,#6e7074,#546570,#c4ccd3",//颜色,默认
click: function (params) {
var url = "/mobilemode/mobile/demo/plugin/NewChart/detail.html?name=" + params.name + "&seriesname=" + params.seriesName + "&value=" + params.value;
$u({ url: url, ajax: true });
}
}
}).render().then(function() {
if (!hasClsPicker) return;
_u.vetically("#barchart-a");
clsPicker.golalSetting({
container: ".wev-comp-BarChart",
type: "BarChart"
});
new clsPicker({
selector: ".wev-chart-container",
text: ".wev-chart-container",
lineYSkew: 40,
skew: [5, 9],
position: "top right"
});
});
if(!hasClsPicker) {
new BarChart({
el: "barchart-b",
option: {
dataAxis: "xAxis",//xAxis 横向 yAxis 纵向
data: "/mobilemode/mobile/demo/plugin/BarChart/data.json",//图表数据来源
height: 600,//图表高度
title: {
show: true,
text: "世界人口总量",//标题
subtext: "数据来自网络"//副标题
},
grid: {
top: 60,//上边距
bottom: 60,//底部边距
left: "3%",//左边距
containLabel: true
},
legend: {
show: true,//是否显示图例
bottom: 10,//图例底部边距
textStyle: {
color: "#333"//字体颜色
}
},
axisLabel: {
interval: 0,//坐标标签间隔,0表示显示所有坐标
rotate: 0,//坐标标签旋转角度
textStyle: {
fontSize: 12//坐标标签字体大小
}
},
isShowMarkPoint: false,//在最大和最小柱状上显示具体的数值
isShowMarkLine: false,//在图表上显示一根平均值的标线
color: "#c23531,#2f4554,#61a0a8,#d48265,#91c7ae,#749f83,#ca8622,#bda29a,#6e7074,#546570,#c4ccd3",//颜色,默认
click: function (params) {
var url = "/mobilemode/mobile/demo/plugin/NewChart/detail.html?ajax=true&name=" + params.name + "&seriesname=" + params.seriesName + "&value=" + params.value;
$u(url);
}
}
}).render();
}
});
</script>