jmchart 1.2.19 → 1.2.21
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.
- package/README.md +253 -20
- package/dist/jmchart.amd.js +3136 -678
- package/dist/jmchart.cjs.js +3136 -678
- package/dist/jmchart.esm.js +3136 -678
- package/dist/jmchart.iife.js +3136 -678
- package/dist/jmchart.system.js +3136 -678
- package/index.d.ts +553 -32
- package/package.json +2 -2
- package/server.js +3 -0
- package/src/common/tooltip.js +3 -3
- package/src/common/utils.js +1 -1
- package/src/core/axis/axis.js +2 -2
- package/src/core/legend/legend.js +106 -108
- package/src/core/markLine/manager.js +2 -0
- package/src/core/markLine/markLine.js +3 -2
- package/src/jmChart.js +2 -5
- package/src/series/areaSeries.js +6 -6
- package/src/series/boxPlotSeries.js +2 -4
- package/src/series/bubbleSeries.js +3 -8
- package/src/series/candlestickSeries.js +1 -5
- package/src/series/funnelSeries.js +1 -3
- package/src/series/gaugeSeries.js +3 -7
- package/src/series/heatmapSeries.js +3 -8
- package/src/series/lineSeries.js +7 -10
- package/src/series/pieSeries.js +36 -31
- package/src/series/radarSeries.js +30 -51
- package/src/series/rangeSeries.js +9 -12
- package/src/series/ringProgressSeries.js +0 -2
- package/src/series/scatterSeries.js +3 -8
- package/src/series/stackBarSeries.js +3 -2
- package/src/series/stackLineSeries.js +0 -4
- package/src/series/waterfallSeries.js +0 -4
- package/src/series/wordCloudSeries.js +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jmchart",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
4
4
|
"description": "chart",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://surl.fit/tools/tools/jmchart",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"jmgraph": "^3.2.
|
|
32
|
+
"jmgraph": "^3.2.29"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"registry": "https://registry.npmjs.org/"
|
package/server.js
CHANGED
|
@@ -53,6 +53,9 @@ function startServer() {
|
|
|
53
53
|
if (!serverInstance) {
|
|
54
54
|
const app = express();
|
|
55
55
|
app.use(express.static("."));
|
|
56
|
+
app.get("*", (req, res) => {
|
|
57
|
+
res.sendFile("example/index.html", { root: __dirname });
|
|
58
|
+
});
|
|
56
59
|
serverInstance = app.listen(port, ip, () => {
|
|
57
60
|
console.log(`\n🔥 开发服务器启动成功!`);
|
|
58
61
|
console.log(`🌐 访问地址: http://${ip}:${port}`);
|
package/src/common/tooltip.js
CHANGED
package/src/common/utils.js
CHANGED
package/src/core/axis/axis.js
CHANGED
|
@@ -199,7 +199,7 @@ export default class jmAxis extends jmArrowLine {
|
|
|
199
199
|
const index = this.index || 1;
|
|
200
200
|
// 如果是雷达图,则画发散的线
|
|
201
201
|
if(this.radarOption) {
|
|
202
|
-
this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left
|
|
202
|
+
this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left;
|
|
203
203
|
this.end.y = this.radarOption.center.y - this.radarOption.sin * this.radarOption.radius + bounds.top;
|
|
204
204
|
this.start.x = this.radarOption.center.x + bounds.left;
|
|
205
205
|
this.start.y = this.radarOption.center.y + bounds.top;
|
|
@@ -602,7 +602,7 @@ export default class jmAxis extends jmArrowLine {
|
|
|
602
602
|
/**
|
|
603
603
|
* 获取或设置当前轴最小值
|
|
604
604
|
*
|
|
605
|
-
* @method
|
|
605
|
+
* @method min
|
|
606
606
|
* @param {number/date/string} 当前轴的最小值
|
|
607
607
|
* @return 当前轴的最小值
|
|
608
608
|
*/
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export default class jmLegend extends jmRect {
|
|
14
|
-
|
|
15
14
|
constructor(options) {
|
|
16
15
|
//当前图例位置偏移量
|
|
17
16
|
options.position = options.position || {
|
|
@@ -25,122 +24,121 @@ export default class jmLegend extends jmRect {
|
|
|
25
24
|
* 图例放置位置
|
|
26
25
|
*/
|
|
27
26
|
legendPosition = '';
|
|
28
|
-
}
|
|
29
27
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 添加图例
|
|
30
|
+
*
|
|
31
|
+
* @method append
|
|
32
|
+
* @param {jmSeries} series 当前图序列
|
|
33
|
+
* @param {jmControl} shape 当前图例的图形对象
|
|
34
|
+
*/
|
|
35
|
+
append(series, shape, options = {}) {
|
|
36
|
+
// 如果不显示图例,就不处理
|
|
37
|
+
if(this.visible === false) return;
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const panel = this.graph.createShape('rect',{
|
|
40
|
+
style: this.graph.utils.clone(this.style.item),
|
|
41
|
+
position: {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.children.add(panel);
|
|
48
|
+
panel.children.add(shape);
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
shape.width = panel.style.shape.width;
|
|
51
|
+
shape.height = panel.style.shape.height;
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
let name = options.name || series.legendLabel;
|
|
54
|
+
name = series.option.legendFormat? series.option.legendFormat.call(series, options): name;
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
if(name) {
|
|
57
|
+
//生成图例名称
|
|
58
|
+
const label = this.graph.createShape('label', {
|
|
59
|
+
style: panel.style.label,
|
|
60
|
+
text: name || ''
|
|
61
|
+
});
|
|
62
|
+
label.height = shape.height;
|
|
63
|
+
label.position = {x: shape.width + 4, y: 0};
|
|
64
|
+
panel.children.add(label);
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
panel.width = shape.width + label.testSize().width;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
panel.width = shape.width;
|
|
70
|
+
}
|
|
71
|
+
panel.height = shape.height;
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
//执行进入事件
|
|
74
|
+
options.hover && panel.bind('mouseover touchover', options.hover);
|
|
75
|
+
options.leave && panel.bind('mouseleave touchleave', options.leave);
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
78
|
+
if(legendPosition == 'top' || legendPosition == 'bottom') {
|
|
79
|
+
//顶部和底部图例横排,每次右移位一个单位图例
|
|
80
|
+
panel.position.x = this.width + 15;
|
|
81
|
+
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
82
|
+
this.height = Math.max(panel.height, this.height);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
//右边和左边图例竖排
|
|
86
|
+
panel.position.y += this.height + 5;
|
|
87
|
+
this.height = panel.position.y + panel.height;
|
|
88
|
+
this.width = Math.max(panel.width, this.width);
|
|
89
|
+
}
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
}
|
|
91
|
+
this.needUpdate = true;
|
|
92
|
+
}
|
|
95
93
|
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
94
|
+
/**
|
|
95
|
+
* 初始化图例
|
|
96
|
+
*
|
|
97
|
+
* @method init
|
|
98
|
+
*/
|
|
99
|
+
init() {
|
|
100
|
+
this.position.x = 0;
|
|
101
|
+
this.position.y = 0;
|
|
102
|
+
this.width = 0;
|
|
103
|
+
this.height = 0;
|
|
104
|
+
this.style.lineWidth = 0;
|
|
105
|
+
this.children.clear();
|
|
106
|
+
}
|
|
109
107
|
|
|
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
|
-
}
|
|
108
|
+
/**
|
|
109
|
+
* 重置图例属性,根据图例内容计算期大小并更新画图区域大小
|
|
110
|
+
*
|
|
111
|
+
* @method reset
|
|
112
|
+
*/
|
|
113
|
+
reset() {
|
|
114
|
+
if(this.visible !== false) {
|
|
115
|
+
this.position.x = this.graph.chartArea.position.x;
|
|
116
|
+
this.position.y = this.graph.chartArea.position.y;
|
|
117
|
+
const legendPosition = this.legendPosition || this.style.legendPosition;
|
|
118
|
+
switch(legendPosition) {
|
|
119
|
+
case 'left': {
|
|
120
|
+
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
121
|
+
//画图区域向右偏移
|
|
122
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case 'top': {
|
|
126
|
+
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
127
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case 'bottom': {
|
|
131
|
+
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
132
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case 'right':
|
|
136
|
+
default: {
|
|
137
|
+
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
138
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
144
142
|
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -3,7 +3,7 @@ import { jmList, jmLine } from 'jmgraph';
|
|
|
3
3
|
/**
|
|
4
4
|
* 轴
|
|
5
5
|
*
|
|
6
|
-
* @class
|
|
6
|
+
* @class jmMarkLine
|
|
7
7
|
* @module jmChart
|
|
8
8
|
* @param {jmChart} chart 当前图表
|
|
9
9
|
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
@@ -69,7 +69,8 @@ export default class jmMarkLine extends jmLine {
|
|
|
69
69
|
// 如果在操作图层上, 点的X轴需要加上图表图层区域偏移量
|
|
70
70
|
this.start.x = this.end.x = isTocuhGraph? (point.x + graph.chartArea.position.x): point.x;
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
const points = point.points || (point.y !== undefined ? [point] : []);
|
|
73
|
+
for(const p of points) {
|
|
73
74
|
if(!p || typeof p.y === 'undefined') continue;
|
|
74
75
|
this.markArc = graph.createShape('circle', {
|
|
75
76
|
style: this.style,
|
package/src/jmChart.js
CHANGED
|
@@ -27,9 +27,6 @@ import jmBoxPlotSeries from './series/boxPlotSeries.js';
|
|
|
27
27
|
import jmWordCloudSeries from './series/wordCloudSeries.js';
|
|
28
28
|
import jmMarkLineManager from './core/markLine/manager';
|
|
29
29
|
|
|
30
|
-
const ANIMATION_DATA_THRESHOLD = 100;
|
|
31
|
-
const DEFAULT_ANIMATION_COUNT = 10;
|
|
32
|
-
|
|
33
30
|
/**
|
|
34
31
|
* jm图表组件
|
|
35
32
|
* option参数:graph=jmgraph
|
|
@@ -47,7 +44,7 @@ export default class jmChart extends jmGraph {
|
|
|
47
44
|
options.autoRefresh = typeof options.autoRefresh === 'undefined' ? enableAnimate : options.autoRefresh;
|
|
48
45
|
|
|
49
46
|
if(enableAnimate && !options.autoRefresh) {
|
|
50
|
-
console.warn('
|
|
47
|
+
console.warn('开启了动画,却没有开启自动刷新');
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
options.style = jmUtils.clone(defaultStyle, options.style, true);
|
|
@@ -409,7 +406,7 @@ export default class jmChart extends jmGraph {
|
|
|
409
406
|
options.maxYValue = typeof options.maxYValue === 'undefined'?this.option.maxYValue:Math.max(this.option.maxYValue, options.maxYValue);
|
|
410
407
|
}
|
|
411
408
|
|
|
412
|
-
|
|
409
|
+
const yaxis = this.yAxises[options.index] || (this.yAxises[options.index] = this.createAxis(options));
|
|
413
410
|
return yaxis;
|
|
414
411
|
}
|
|
415
412
|
|
package/src/series/areaSeries.js
CHANGED
|
@@ -20,16 +20,16 @@ export default class jmAreaSeries extends jmLineSeries {
|
|
|
20
20
|
* 生成图例
|
|
21
21
|
*/
|
|
22
22
|
createLegend() {
|
|
23
|
-
|
|
23
|
+
const style = this.graph.utils.clone(this.style);
|
|
24
24
|
style.stroke = style.color;
|
|
25
25
|
style.fill = style.color;
|
|
26
|
-
|
|
26
|
+
const shape = this.graph.createShape('path',{style:style});
|
|
27
27
|
|
|
28
28
|
if(this.curve || this.style.curve) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const p1 = {x:0,y: this.graph.style.legend.item.shape.height};
|
|
30
|
+
const p2 = {x:this.graph.style.legend.item.shape.width / 3,y:this.graph.style.legend.item.shape.height/3};
|
|
31
|
+
const p3 = {x:this.graph.style.legend.item.shape.width / 3 * 2,y:this.graph.style.legend.item.shape.height/3*2};
|
|
32
|
+
const p4 = {x:this.graph.style.legend.item.shape.width,y:0};
|
|
33
33
|
|
|
34
34
|
this.__bezier = this.__bezier || this.graph.createShape('bezier');
|
|
35
35
|
this.__bezier.cpoints = [
|
|
@@ -59,8 +59,8 @@ export default class jmBoxPlotSeries extends jmSeries {
|
|
|
59
59
|
|
|
60
60
|
if(allValues.length === 0) return;
|
|
61
61
|
|
|
62
|
-
const minValue = Math.min(
|
|
63
|
-
const maxValue = Math.max(
|
|
62
|
+
const minValue = allValues.reduce((a, b) => Math.min(a, b));
|
|
63
|
+
const maxValue = allValues.reduce((a, b) => Math.max(a, b));
|
|
64
64
|
const valueRange = maxValue - minValue || 1;
|
|
65
65
|
|
|
66
66
|
const boxWidth = this.style.boxWidth || (chartWidth / data.length * 0.5);
|
|
@@ -250,5 +250,3 @@ export default class jmBoxPlotSeries extends jmSeries {
|
|
|
250
250
|
this.graph.legend.append(this, shape);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
export { jmBoxPlotSeries };
|
|
@@ -107,13 +107,12 @@ export default class jmBubbleSeries extends jmSeries {
|
|
|
107
107
|
* @for jmBubbleSeries
|
|
108
108
|
*/
|
|
109
109
|
createLegend() {
|
|
110
|
-
|
|
111
|
-
var style = this.graph.utils.clone(this.style);
|
|
110
|
+
const style = this.graph.utils.clone(this.style);
|
|
112
111
|
style.stroke = style.color;
|
|
113
112
|
style.fill = style.color;
|
|
114
113
|
style.opacity = style.opacity || 0.6;
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
|
|
115
|
+
const shape = this.graph.createShape('circle', {
|
|
117
116
|
style: style,
|
|
118
117
|
center: {
|
|
119
118
|
x: this.graph.style.legend.item.shape.width / 2,
|
|
@@ -124,8 +123,4 @@ export default class jmBubbleSeries extends jmSeries {
|
|
|
124
123
|
|
|
125
124
|
this.graph.legend.append(this, shape);
|
|
126
125
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
jmBubbleSeries
|
|
131
126
|
}
|
|
@@ -28,7 +28,7 @@ import jmSeries from './series.js';
|
|
|
28
28
|
|
|
29
29
|
export default class jmCandlestickSeries extends jmSeries {
|
|
30
30
|
constructor(options) {
|
|
31
|
-
options.style = options.style || options.graph.style.line;
|
|
31
|
+
options.style = options.style || options.graph.style.candlestick || options.graph.style.line;
|
|
32
32
|
super(options);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -123,7 +123,3 @@ export default class jmCandlestickSeries extends jmSeries {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
jmCandlestickSeries
|
|
129
|
-
}
|
|
@@ -50,7 +50,7 @@ export default class jmFunnelSeries extends jmSeries {
|
|
|
50
50
|
const xField = this.option.xField || 'name';
|
|
51
51
|
|
|
52
52
|
const values = data.map(item => Math.abs(item[field] || 0));
|
|
53
|
-
const maxValue = Math.max(
|
|
53
|
+
const maxValue = values.reduce((a, b) => Math.max(a, b));
|
|
54
54
|
|
|
55
55
|
if(maxValue === 0) return;
|
|
56
56
|
|
|
@@ -186,5 +186,3 @@ export default class jmFunnelSeries extends jmSeries {
|
|
|
186
186
|
this.graph.legend.append(this, shape);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
|
|
190
|
-
export { jmFunnelSeries };
|
|
@@ -238,11 +238,11 @@ export default class jmGaugeSeries extends jmSeries {
|
|
|
238
238
|
* 生成图例
|
|
239
239
|
*/
|
|
240
240
|
createLegend() {
|
|
241
|
-
|
|
241
|
+
const style = this.graph.utils.clone(this.style);
|
|
242
242
|
style.stroke = style.color;
|
|
243
243
|
style.fill = style.color;
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
|
|
245
|
+
const shape = this.graph.createShape('arc', {
|
|
246
246
|
style: style,
|
|
247
247
|
center: {
|
|
248
248
|
x: this.graph.style.legend.item.shape.width / 2,
|
|
@@ -256,7 +256,3 @@ export default class jmGaugeSeries extends jmSeries {
|
|
|
256
256
|
this.graph.legend.append(this, shape);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
export {
|
|
261
|
-
jmGaugeSeries
|
|
262
|
-
}
|
|
@@ -160,12 +160,11 @@ export default class jmHeatmapSeries extends jmSeries {
|
|
|
160
160
|
* @for jmHeatmapSeries
|
|
161
161
|
*/
|
|
162
162
|
createLegend() {
|
|
163
|
-
|
|
164
|
-
var style = this.graph.utils.clone(this.style);
|
|
163
|
+
const style = this.graph.utils.clone(this.style);
|
|
165
164
|
style.stroke = style.color;
|
|
166
165
|
style.fill = style.color;
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
|
|
167
|
+
const shape = this.graph.createShape('rect', {
|
|
169
168
|
style: style,
|
|
170
169
|
position: {
|
|
171
170
|
x: 0,
|
|
@@ -177,8 +176,4 @@ export default class jmHeatmapSeries extends jmSeries {
|
|
|
177
176
|
|
|
178
177
|
this.graph.legend.append(this, shape);
|
|
179
178
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export {
|
|
183
|
-
jmHeatmapSeries
|
|
184
179
|
}
|
package/src/series/lineSeries.js
CHANGED
|
@@ -33,6 +33,7 @@ export default class jmLineSeries extends jmSeries {
|
|
|
33
33
|
if(!len) return;
|
|
34
34
|
|
|
35
35
|
this.style.stroke = this.style.color;
|
|
36
|
+
this.style.fill = null;
|
|
36
37
|
this.style.item.stroke = this.style.color;
|
|
37
38
|
|
|
38
39
|
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
@@ -161,9 +162,9 @@ export default class jmLineSeries extends jmSeries {
|
|
|
161
162
|
createLegend() {
|
|
162
163
|
|
|
163
164
|
//生成图例前的图标
|
|
164
|
-
|
|
165
|
+
const style = this.graph.utils.clone(this.style);
|
|
165
166
|
style.stroke = style.color;
|
|
166
|
-
|
|
167
|
+
const shape = this.graph.createShape('path',{style:style});
|
|
167
168
|
|
|
168
169
|
if(this.curve || this.style.curve) {
|
|
169
170
|
var p1 = {x:0,y: this.graph.style.legend.item.shape.height};
|
|
@@ -193,10 +194,8 @@ export default class jmLineSeries extends jmSeries {
|
|
|
193
194
|
// 有指定绘制区域效果才展示
|
|
194
195
|
if(!this.style.area || points.length < 2) return;
|
|
195
196
|
|
|
196
|
-
//
|
|
197
|
-
const axisY = this.
|
|
198
|
-
? this.graph.xAxis.start.y - this.graph.chartArea.position.y
|
|
199
|
-
: this.graph.chartArea.height;
|
|
197
|
+
// 基线:使用数据基准线(baseY),在 createPoints 中已根据 minY/baseYValue 正确计算
|
|
198
|
+
const axisY = this.baseY;
|
|
200
199
|
|
|
201
200
|
// 过滤有效点
|
|
202
201
|
const validPoints = points.filter(p => p.y != null && typeof p.y !== 'undefined');
|
|
@@ -233,6 +232,8 @@ export default class jmLineSeries extends jmSeries {
|
|
|
233
232
|
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
234
233
|
// 连框颜色如果没指定,就透明
|
|
235
234
|
style.stroke = style.stroke || 'transparent';
|
|
235
|
+
// 闭合路径,确保 fill/stroke 正确封闭多边形
|
|
236
|
+
style.close = true;
|
|
236
237
|
|
|
237
238
|
if(!style.fill) {
|
|
238
239
|
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
@@ -332,7 +333,3 @@ export default class jmLineSeries extends jmSeries {
|
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
|
-
|
|
336
|
-
export {
|
|
337
|
-
jmLineSeries
|
|
338
|
-
}
|
package/src/series/pieSeries.js
CHANGED
|
@@ -122,7 +122,7 @@ export default class jmPieSeries extends jmSeries {
|
|
|
122
122
|
// 每项之间的间隔角度 顺时钟为正,否则为负
|
|
123
123
|
const marginAngle = (Number(this.style.marginAngle) || 0);
|
|
124
124
|
|
|
125
|
-
for(
|
|
125
|
+
for(let i=0;i< this.data.length;i++) {
|
|
126
126
|
const s = this.data[i];
|
|
127
127
|
|
|
128
128
|
const yv = s[this.field];
|
|
@@ -186,6 +186,7 @@ export default class jmPieSeries extends jmSeries {
|
|
|
186
186
|
startAngle: p.startAngle,
|
|
187
187
|
endAngle: p.endAngle,
|
|
188
188
|
anticlockwise: anticlockwise,
|
|
189
|
+
interactive: true,
|
|
189
190
|
isFan: true, // 表示画扇形
|
|
190
191
|
center: p.center,
|
|
191
192
|
radius: p.radius,
|
|
@@ -219,6 +220,9 @@ export default class jmPieSeries extends jmSeries {
|
|
|
219
220
|
this.addShape(p.shape);
|
|
220
221
|
|
|
221
222
|
// 如果有点击事件
|
|
223
|
+
if(this.option.onClick || this.option.onOver || this.option.onLeave) {
|
|
224
|
+
p.shape.interactive = true;
|
|
225
|
+
}
|
|
222
226
|
if(this.option.onClick) {
|
|
223
227
|
p.shape.on('click', (e) => {
|
|
224
228
|
return this.option.onClick.call(this, p, e);
|
|
@@ -302,38 +306,39 @@ export default class jmPieSeries extends jmSeries {
|
|
|
302
306
|
|
|
303
307
|
point.shape.children.add(label);
|
|
304
308
|
}
|
|
305
|
-
}
|
|
306
309
|
|
|
310
|
+
/**
|
|
311
|
+
* 生成图例
|
|
312
|
+
*
|
|
313
|
+
* @method createLegend
|
|
314
|
+
*/
|
|
315
|
+
createLegend() {
|
|
316
|
+
if(!this.data || !this.data.length) return;
|
|
307
317
|
|
|
318
|
+
const len = this.data.length;
|
|
319
|
+
for(let k = 0; k < len; k++) {
|
|
320
|
+
const s = this.data[k];
|
|
321
|
+
if(!s) continue;
|
|
322
|
+
const yv = s[this.field];
|
|
323
|
+
if(yv == null || typeof yv === 'undefined') continue;
|
|
308
324
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const shape = this.graph.createShape('rect',{
|
|
328
|
-
style: style,
|
|
329
|
-
position : {x: 0, y: 0}
|
|
330
|
-
});
|
|
331
|
-
//shape.targetShape = p.shape;
|
|
332
|
-
//此处重写图例事件
|
|
333
|
-
this.graph.legend.append(this, shape, {
|
|
334
|
-
name: this.legendLabel,
|
|
335
|
-
data: this.data[k]
|
|
336
|
-
});
|
|
337
|
-
}
|
|
325
|
+
const style = this.graph.utils.clone(this.style);
|
|
326
|
+
if(style.color && typeof style.color === 'function') {
|
|
327
|
+
style.fill = style.color.call(this, { data: s, index: k });
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
style.fill = this.graph.getColor(k);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const shape = this.graph.createShape('rect',{
|
|
334
|
+
style: style,
|
|
335
|
+
position : {x: 0, y: 0}
|
|
336
|
+
});
|
|
337
|
+
this.graph.legend.append(this, shape, {
|
|
338
|
+
name: this.legendLabel,
|
|
339
|
+
data: s
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
338
343
|
}
|
|
339
344
|
|