jmchart 1.1.81 → 1.1.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,143 +1,143 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
7
-
8
- <style>
9
- html,body {
10
- margin:0;
11
- padding:0;
12
- width:100%;
13
- height:100%;
14
- }
15
- #mycanvas canvas, #mycanvas div{
16
- background-color:#fff;
17
- margin:0 auto;
18
- }
19
- /*div.jm-tooltip {
20
- background-color: rgba(255,255,255,0.8);
21
- padding:4px;
22
- border:1px solid #000;
23
- box-shadow: 0 0 3px #000;
24
- border-radius: 6px;
25
- }*/
26
- </style>
27
- <script type="module">
28
- //window.devicePixelRatio = 1;
29
- import { jmChart } from '../dist/jmchart.esm.js';
30
-
31
- (function load() {
32
- var w = Math.max((window.innerWidth || window.document.body.clientWidth) * 0.9, 600);
33
- var h = Math.max((window.innerHeight || window.document.body.clientHeight) * 0.6, 200);
34
- inichart(w,h);
35
- })();
36
-
37
-
38
- function inichart(w, h) {
39
- var chart = new jmChart('mycanvas', {
40
- width: w,
41
- height: h,
42
- xField: 'x',
43
- baseY: 0,
44
- // 最大和最小X值, 这里一般不用指定,除非硬是需要
45
- minXValue : 0,
46
- maxXValue : 10,
47
- autoRefresh: true
48
- });
49
- chart.legend.legendPosition = 'top';
50
- chart.legend.visible = true;
51
- chart.enableAnimate = true;
52
-
53
- // touch改变数据点事件
54
- chart.on('touchPointChange', function(args) {
55
- console.log(args);
56
- });
57
-
58
-
59
- var bar = chart.createSeries('stackBar', {
60
- field: ['y1', 'y2', 'y3'],
61
- // 图例格式化,如果不给定,则采用legendLabel
62
- legendFormat: function(options) {
63
- return '图1';
64
- },
65
- yLabelFormat: (v, label) => {
66
- return v.toFixed(0);
67
- }
68
- });
69
- var line = chart.createSeries('line', {
70
- field: 'y4',
71
- legendLabel: 'line',
72
- style: {
73
- showItem: false,
74
- lineWidth: 3,
75
- curve: true,
76
- //lineType: 'dotted', // 虚线
77
- shadow: function() {
78
- return `2, 2, 10, ${this.style.stroke}`;
79
- },
80
- }
81
- });
82
-
83
- const datacount = 10;
84
- function animate() {
85
- if(true) {
86
- chart.data = [];
87
- for(var i = 0;i<datacount;i++) {
88
- var data = {
89
- x : i,
90
- y1 : Math.random() * 200 - 100,
91
- y2: Math.random() * 200 + 50,
92
- y3: Math.random() * 200 + 50,
93
- };
94
-
95
- data.y4 = data.y1;
96
- if(data.y4 <= 0) {
97
- if(data.y2 <= 0) data.y4 += data.y2;
98
- else data.y4 = data.y2;
99
- }
100
- else {
101
- if(data.y2 > 0) data.y4 += data.y2;
102
- }
103
- if(data.y4 <= 0) {
104
- if(data.y3 <= 0) data.y4 += data.y3;
105
- else data.y4 = data.y3;
106
- }
107
- else {
108
- if(data.y3 > 0) data.y4 += data.y3;
109
- }
110
- chart.data.push(data);
111
- }
112
- }
113
- else {
114
- for(var i=datacount-1;i>0;i--) {
115
- var x = chart.data[i].x;
116
- chart.data[i] = chart.utils.clone(chart.data[i - 1]);
117
- chart.data[i].x = x;
118
- }
119
-
120
- chart.source[0] = {
121
- x : chart.data[0].x,
122
- y : Math.random() * 200 - 100
123
- };
124
-
125
- }
126
-
127
- //setTimeout(animate,500);
128
- chart.refresh();
129
- console.log(chart.data);
130
- }
131
-
132
- animate();
133
- chart.utils.bindEvent(document.getElementById('btnRedraw'),'click',animate);
134
-
135
- }
136
- </script>
137
- </head>
138
- <body>
139
- <div id="mycanvas">
140
- </div>
141
- <button id="btnRedraw">重绘</button>
142
- </body>
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
7
+
8
+ <style>
9
+ html,body {
10
+ margin:0;
11
+ padding:0;
12
+ width:100%;
13
+ height:100%;
14
+ }
15
+ #mycanvas canvas, #mycanvas div{
16
+ background-color:#fff;
17
+ margin:0 auto;
18
+ }
19
+ /*div.jm-tooltip {
20
+ background-color: rgba(255,255,255,0.8);
21
+ padding:4px;
22
+ border:1px solid #000;
23
+ box-shadow: 0 0 3px #000;
24
+ border-radius: 6px;
25
+ }*/
26
+ </style>
27
+ <script type="module">
28
+ //window.devicePixelRatio = 1;
29
+ import { jmChart } from '../dist/jmchart.esm.js';
30
+
31
+ (function load() {
32
+ var w = Math.max((window.innerWidth || window.document.body.clientWidth) * 0.9, 600);
33
+ var h = Math.max((window.innerHeight || window.document.body.clientHeight) * 0.6, 200);
34
+ inichart(w,h);
35
+ })();
36
+
37
+
38
+ function inichart(w, h) {
39
+ var chart = new jmChart('mycanvas', {
40
+ width: w,
41
+ height: h,
42
+ xField: 'x',
43
+ baseY: 0,
44
+ // 最大和最小X值, 这里一般不用指定,除非硬是需要
45
+ minXValue : 0,
46
+ maxXValue : 10,
47
+ autoRefresh: true
48
+ });
49
+ chart.legend.legendPosition = 'top';
50
+ chart.legend.visible = true;
51
+ chart.enableAnimate = true;
52
+
53
+ // touch改变数据点事件
54
+ chart.on('touchPointChange', function(args) {
55
+ console.log(args);
56
+ });
57
+
58
+
59
+ var bar = chart.createSeries('stackBar', {
60
+ field: ['y1', 'y2', 'y3'],
61
+ // 图例格式化,如果不给定,则采用legendLabel
62
+ legendFormat: function(options) {
63
+ return '图1';
64
+ },
65
+ yLabelFormat: (v, label) => {
66
+ return v.toFixed(0);
67
+ }
68
+ });
69
+ var line = chart.createSeries('line', {
70
+ field: 'y4',
71
+ legendLabel: 'line',
72
+ style: {
73
+ showItem: false,
74
+ lineWidth: 3,
75
+ curve: true,
76
+ //lineType: 'dotted', // 虚线
77
+ shadow: function() {
78
+ return `2, 2, 10, ${this.style.stroke}`;
79
+ },
80
+ }
81
+ });
82
+
83
+ const datacount = 10;
84
+ function animate() {
85
+ if(true) {
86
+ chart.data = [];
87
+ for(var i = 0;i<datacount;i++) {
88
+ var data = {
89
+ x : i,
90
+ y1 : Math.random() * 200 - 100,
91
+ y2: Math.random() * 200 + 50,
92
+ y3: Math.random() * 200 + 50,
93
+ };
94
+
95
+ data.y4 = data.y1;
96
+ if(data.y4 <= 0) {
97
+ if(data.y2 <= 0) data.y4 += data.y2;
98
+ else data.y4 = data.y2;
99
+ }
100
+ else {
101
+ if(data.y2 > 0) data.y4 += data.y2;
102
+ }
103
+ if(data.y4 <= 0) {
104
+ if(data.y3 <= 0) data.y4 += data.y3;
105
+ else data.y4 = data.y3;
106
+ }
107
+ else {
108
+ if(data.y3 > 0) data.y4 += data.y3;
109
+ }
110
+ chart.data.push(data);
111
+ }
112
+ }
113
+ else {
114
+ for(var i=datacount-1;i>0;i--) {
115
+ var x = chart.data[i].x;
116
+ chart.data[i] = chart.utils.clone(chart.data[i - 1]);
117
+ chart.data[i].x = x;
118
+ }
119
+
120
+ chart.source[0] = {
121
+ x : chart.data[0].x,
122
+ y : Math.random() * 200 - 100
123
+ };
124
+
125
+ }
126
+
127
+ //setTimeout(animate,500);
128
+ chart.refresh();
129
+ console.log(chart.data);
130
+ }
131
+
132
+ animate();
133
+ chart.utils.bindEvent(document.getElementById('btnRedraw'),'click',animate);
134
+
135
+ }
136
+ </script>
137
+ </head>
138
+ <body>
139
+ <div id="mycanvas">
140
+ </div>
141
+ <button id="btnRedraw">重绘</button>
142
+ </body>
143
143
  </html>
@@ -1,148 +1,148 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
7
-
8
- <style>
9
- html,body {
10
- margin:0;
11
- padding:0;
12
- width:100%;
13
- height:100%;
14
- }
15
- #mycanvas {
16
- text-align: center;
17
- margin-top: 10px;
18
- }
19
- #mycanvas canvas, #mycanvas div{
20
- background-color:#fff;
21
- margin:0 auto;
22
- }
23
- /*div.jm-tooltip {
24
- background-color: rgba(255,255,255,0.8);
25
- padding:4px;
26
- border:1px solid #000;
27
- box-shadow: 0 0 3px #000;
28
- border-radius: 6px;
29
- }*/
30
- </style>
31
- <script type="module">
32
- import jmChart from '../dist/jmchart.esm.js';
33
- (function load() {
34
- var w = Math.max((window.innerWidth || window.document.body.clientWidth) * 0.8, 500);
35
- var h = Math.min((window.innerHeight || window.document.body.clientHeight) * 0.5, 500);
36
- inichart(w,h);
37
- })();
38
-
39
-
40
- function inichart(w, h) {
41
-
42
- const datacount = 50;
43
-
44
- const chart = new jmChart('mycanvas', {
45
- width: w,
46
- height: h,
47
- xField: 'x',
48
- enableAnimate: true,
49
- legendPosition: 'top',
50
- legendVisible: false, // 不显示图例
51
- // 最大和最小X值, 这里一般不用指定,除非硬是需要
52
- minXValue : 0,
53
- maxXValue : 10,
54
- //minYValue: -100,
55
- //maxYValue: 400,
56
- // 格式化x标签值
57
- xLabelFormat: (v, item, index) => {
58
- // 只展示第一个和最后一个
59
- if(index % 5 === 0) {
60
- return v;
61
- }
62
- return '';
63
- },
64
- style: {
65
- // 跟随标线
66
- markLine: {
67
- x: false, // 显示X标线
68
- y: true, // 显示Y标线
69
- stroke: 'red',
70
- fill: '#fff',
71
- lineWidth: 1,
72
- },
73
- // x轴 Y轴隐藏
74
- axis: {
75
- stroke: 'transparent',
76
- align: 'center', // label居中对齐
77
- grid: {
78
- x: false, // 不显示X轴网格
79
- y: true // 显示Y轴网格
80
- }
81
- },
82
- // 隐藏边框
83
- chartArea: {
84
- stroke: 'transparent'
85
- },
86
- margin: {
87
- top: 30,
88
- left: 50,
89
- right: 10,
90
- bottom: 30
91
- }
92
- }
93
- });
94
-
95
- const line = chart.createSeries('stackLine', {
96
- fields: [
97
- 'y1', 'y2'
98
- ],
99
- //index: 2, // 指定Y轴索引,如是档指定就会共用左边的Y轴,
100
- legendLabel: '图例2',
101
-
102
- // 格式化x轴标签值
103
- yLabelFormat: (v) => {
104
- return v.toFixed? (v.toFixed(0) + '%') : v;
105
- },
106
- style: {
107
- // 不显示小圆点
108
- showItem: false,
109
- color: '#F7BB98',
110
- // 填充图形
111
- area: {
112
- fill: function(style) {
113
- return this.style.color;
114
- },
115
- shadow: function() {
116
- return `0, 0, 20, #000`;
117
- },
118
- }
119
- }
120
- });
121
-
122
-
123
- function animate() {
124
- chart.data = [];
125
- for(var i = 0;i<datacount;i++) {
126
- const d = {
127
- x : '0909' + i,
128
- y1 : i * 2 + Math.random() * 10,
129
- y2: i * 3 + Math.random() * 10
130
- };
131
-
132
- chart.data.push(d);
133
- }
134
-
135
- //setTimeout(animate,500);
136
- chart.refresh();
137
- console.log(chart.data);
138
- }
139
-
140
- animate();
141
- }
142
- </script>
143
- </head>
144
- <body>
145
- <div id="mycanvas">
146
- </div>
147
- </body>
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
7
+
8
+ <style>
9
+ html,body {
10
+ margin:0;
11
+ padding:0;
12
+ width:100%;
13
+ height:100%;
14
+ }
15
+ #mycanvas {
16
+ text-align: center;
17
+ margin-top: 10px;
18
+ }
19
+ #mycanvas canvas, #mycanvas div{
20
+ background-color:#fff;
21
+ margin:0 auto;
22
+ }
23
+ /*div.jm-tooltip {
24
+ background-color: rgba(255,255,255,0.8);
25
+ padding:4px;
26
+ border:1px solid #000;
27
+ box-shadow: 0 0 3px #000;
28
+ border-radius: 6px;
29
+ }*/
30
+ </style>
31
+ <script type="module">
32
+ import jmChart from '../dist/jmchart.esm.js';
33
+ (function load() {
34
+ var w = Math.max((window.innerWidth || window.document.body.clientWidth) * 0.8, 500);
35
+ var h = Math.min((window.innerHeight || window.document.body.clientHeight) * 0.5, 500);
36
+ inichart(w,h);
37
+ })();
38
+
39
+
40
+ function inichart(w, h) {
41
+
42
+ const datacount = 50;
43
+
44
+ const chart = new jmChart('mycanvas', {
45
+ width: w,
46
+ height: h,
47
+ xField: 'x',
48
+ enableAnimate: true,
49
+ legendPosition: 'top',
50
+ legendVisible: false, // 不显示图例
51
+ // 最大和最小X值, 这里一般不用指定,除非硬是需要
52
+ minXValue : 0,
53
+ maxXValue : 10,
54
+ //minYValue: -100,
55
+ //maxYValue: 400,
56
+ // 格式化x标签值
57
+ xLabelFormat: (v, item, index) => {
58
+ // 只展示第一个和最后一个
59
+ if(index % 5 === 0) {
60
+ return v;
61
+ }
62
+ return '';
63
+ },
64
+ style: {
65
+ // 跟随标线
66
+ markLine: {
67
+ x: false, // 显示X标线
68
+ y: true, // 显示Y标线
69
+ stroke: 'red',
70
+ fill: '#fff',
71
+ lineWidth: 1,
72
+ },
73
+ // x轴 Y轴隐藏
74
+ axis: {
75
+ stroke: 'transparent',
76
+ align: 'center', // label居中对齐
77
+ grid: {
78
+ x: false, // 不显示X轴网格
79
+ y: true // 显示Y轴网格
80
+ }
81
+ },
82
+ // 隐藏边框
83
+ chartArea: {
84
+ stroke: 'transparent'
85
+ },
86
+ margin: {
87
+ top: 30,
88
+ left: 50,
89
+ right: 10,
90
+ bottom: 30
91
+ }
92
+ }
93
+ });
94
+
95
+ const line = chart.createSeries('stackLine', {
96
+ fields: [
97
+ 'y1', 'y2'
98
+ ],
99
+ //index: 2, // 指定Y轴索引,如是档指定就会共用左边的Y轴,
100
+ legendLabel: '图例2',
101
+
102
+ // 格式化x轴标签值
103
+ yLabelFormat: (v) => {
104
+ return v.toFixed? (v.toFixed(0) + '%') : v;
105
+ },
106
+ style: {
107
+ // 不显示小圆点
108
+ showItem: false,
109
+ color: '#F7BB98',
110
+ // 填充图形
111
+ area: {
112
+ fill: function(style) {
113
+ return this.style.color;
114
+ },
115
+ shadow: function() {
116
+ return `0, 0, 20, #000`;
117
+ },
118
+ }
119
+ }
120
+ });
121
+
122
+
123
+ function animate() {
124
+ chart.data = [];
125
+ for(var i = 0;i<datacount;i++) {
126
+ const d = {
127
+ x : '0909' + i,
128
+ y1 : i * 2 + Math.random() * 10,
129
+ y2: i * 3 + Math.random() * 10
130
+ };
131
+
132
+ chart.data.push(d);
133
+ }
134
+
135
+ //setTimeout(animate,500);
136
+ chart.refresh();
137
+ console.log(chart.data);
138
+ }
139
+
140
+ animate();
141
+ }
142
+ </script>
143
+ </head>
144
+ <body>
145
+ <div id="mycanvas">
146
+ </div>
147
+ </body>
148
148
  </html>