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.
- package/README.md +30 -28
- package/build.js +35 -35
- package/dist/jmchart.amd.js +682 -427
- package/dist/jmchart.cjs.js +680 -425
- package/dist/jmchart.esm.js +679 -424
- package/dist/jmchart.iife.js +681 -426
- package/dist/jmchart.system.js +684 -429
- package/example/bar.html +186 -180
- package/example/candlestick.html +288 -0
- package/example/index.html +294 -0
- package/example/js/vconsole.js +10 -0
- package/example/line.html +300 -297
- package/example/pie.html +353 -353
- package/example/stackBar.html +142 -142
- package/example/stackLine.html +147 -147
- package/example/test.html +93 -40
- package/example/vue.html +322 -322
- package/example/wk/line.html +314 -314
- package/index.js +8 -8
- package/package.json +42 -42
- package/rollup.config.js +26 -26
- package/server.js +48 -45
- package/src/common/style.js +259 -242
- package/src/common/tooltip.js +165 -165
- package/src/common/utils.js +21 -21
- package/src/component/vchart.js +130 -130
- package/src/core/axis/axis.js +622 -622
- package/src/core/legend/legend.js +163 -163
- package/src/core/markLine/manager.js +153 -0
- package/src/core/{axis → markLine}/markLine.js +190 -190
- package/src/jmChart.js +416 -464
- package/src/series/barSeries.js +135 -135
- package/src/series/candlestickSeries.js +114 -0
- package/src/series/lineSeries.js +243 -243
- package/src/series/pieSeries.js +350 -350
- package/src/series/series.js +397 -396
- package/src/series/stackBarSeries.js +144 -144
- package/src/series/stackLineSeries.js +145 -145
package/src/series/lineSeries.js
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
|
-
|
|
2
|
-
import jmSeries from './series.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 图形基类
|
|
6
|
-
*
|
|
7
|
-
* @class jmLineSeries
|
|
8
|
-
* @module jmChart
|
|
9
|
-
* @param {jmChart} chart 当前图表
|
|
10
|
-
* @param {array} mappings 图形字段映射
|
|
11
|
-
* @param {style} style 样式
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
//构造函数
|
|
15
|
-
export default class jmLineSeries extends jmSeries {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
options.style = options.style || options.graph.style.line;
|
|
18
|
-
super(options);
|
|
19
|
-
|
|
20
|
-
//this.on('beginDraw', this[PreDrawKey]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 绘制图形前 初始化线条
|
|
25
|
-
*
|
|
26
|
-
* @method preDraw
|
|
27
|
-
* @for jmLineSeries
|
|
28
|
-
*/
|
|
29
|
-
init() {
|
|
30
|
-
//生成描点位
|
|
31
|
-
const {
|
|
32
|
-
points,
|
|
33
|
-
dataChanged
|
|
34
|
-
} = this.initDataPoint();
|
|
35
|
-
|
|
36
|
-
//去除多余的线条
|
|
37
|
-
//当数据源线条数比现有的少时,删除多余的线条
|
|
38
|
-
const len = points.length;
|
|
39
|
-
|
|
40
|
-
//设定其填充颜色
|
|
41
|
-
//if(!this.style.fill) this.style.fill = jmUtils.toColor(this.style.stroke,null,null,20);
|
|
42
|
-
this.style.stroke = this.style.color;
|
|
43
|
-
//是否启用动画效果
|
|
44
|
-
//var ani = typeof this.enableAnimate === 'undefined'? this.graph.enableAnimate: this.enableAnimate;
|
|
45
|
-
this.style.item.stroke = this.style.color;
|
|
46
|
-
|
|
47
|
-
// 是否正在动画中
|
|
48
|
-
// 如果数据点多于100 个,暂时不启用动画,太慢了
|
|
49
|
-
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0 );
|
|
50
|
-
|
|
51
|
-
let shapePoints = []; // 计算出来的曲线点集合
|
|
52
|
-
const aniCount = (this.style.aniCount || 10);
|
|
53
|
-
const aniStep = Math.floor(len / aniCount) || 1;// 每次动画播放点个数
|
|
54
|
-
|
|
55
|
-
for(let i=0; i< len;i++) {
|
|
56
|
-
const p = points[i];
|
|
57
|
-
|
|
58
|
-
//如果当前点无效,则跳致下一点
|
|
59
|
-
if(typeof p.y === 'undefined' || p.y === null) {
|
|
60
|
-
//prePoint = null;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if(isRunningAni) {
|
|
65
|
-
if(i > this.___animateCounter) {
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 是否显示数值点圆
|
|
71
|
-
if(this.style.showItem) {
|
|
72
|
-
this.createPointItem(p);
|
|
73
|
-
}
|
|
74
|
-
// 平滑曲线
|
|
75
|
-
if(this.style.curve) {
|
|
76
|
-
shapePoints = this.createCurePoints(shapePoints, p);
|
|
77
|
-
}
|
|
78
|
-
// 如果是虚线
|
|
79
|
-
else if(this.style.lineType === 'dotted') {
|
|
80
|
-
shapePoints = this.createDotLine(shapePoints, p);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
shapePoints.push(p);
|
|
84
|
-
|
|
85
|
-
this.createItemLabel(p);
|
|
86
|
-
|
|
87
|
-
// 生成关健值标注
|
|
88
|
-
this.emit('onPointCreated', p);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 如果所有都已经结束,则重置成初始化状态
|
|
92
|
-
if(this.___animateCounter >= len - 1) {
|
|
93
|
-
this.___animateCounter = 0;
|
|
94
|
-
}
|
|
95
|
-
else if(isRunningAni) {
|
|
96
|
-
this.___animateCounter += aniStep;
|
|
97
|
-
// next tick 再次刷新
|
|
98
|
-
setTimeout(()=>{
|
|
99
|
-
this.needUpdate = true;//需要刷新
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.points = shapePoints;
|
|
104
|
-
this.createArea(shapePoints);// 仓建区域效果
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 生成点的小圆圈
|
|
108
|
-
createPointItem(p) {
|
|
109
|
-
const pointShape = this.graph.createShape('circle', {
|
|
110
|
-
style: this.style.item,
|
|
111
|
-
center: p,
|
|
112
|
-
radius: this.style.radius || 3
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
pointShape.zIndex = (pointShape.style.zIndex || 1) + 1;
|
|
116
|
-
return this.addShape(pointShape);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 根据上下点生成平滑曲线
|
|
120
|
-
createCurePoints(shapePoints, p) {
|
|
121
|
-
const startPoint = shapePoints[shapePoints.length - 1];
|
|
122
|
-
if(startPoint && startPoint.y != undefined && startPoint.y != null) {
|
|
123
|
-
//如果需要画曲线,则计算贝塞尔曲线坐标
|
|
124
|
-
const p1 = {x: startPoint.x + (p.x - startPoint.x) / 5, y: startPoint.y};
|
|
125
|
-
const p2 = {x: startPoint.x + (p.x - startPoint.x) / 2, y: p.y - (p.y - startPoint.y) / 2};
|
|
126
|
-
const p3 = {x: p.x - (p.x - startPoint.x) / 5, y: p.y};
|
|
127
|
-
|
|
128
|
-
//圆滑线条使用的贝塞尔对象
|
|
129
|
-
this.__bezier = this.__bezier || this.graph.createShape('bezier');
|
|
130
|
-
this.__bezier.cpoints = [
|
|
131
|
-
startPoint,
|
|
132
|
-
p1,
|
|
133
|
-
p2,
|
|
134
|
-
p3,
|
|
135
|
-
p
|
|
136
|
-
];//设置控制点
|
|
137
|
-
|
|
138
|
-
const bzpoints = this.__bezier.initPoints();
|
|
139
|
-
shapePoints = shapePoints.concat(bzpoints);
|
|
140
|
-
}
|
|
141
|
-
return shapePoints;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// 生成虚线
|
|
145
|
-
createDotLine(shapePoints, p) {
|
|
146
|
-
const startPoint = shapePoints[shapePoints.length - 1];
|
|
147
|
-
if(startPoint && startPoint.y != undefined && startPoint.y != null) {
|
|
148
|
-
//使用线条来画虚线效果
|
|
149
|
-
this.__line = this.__line || this.graph.createShape('line', {
|
|
150
|
-
style: this.style,
|
|
151
|
-
});
|
|
152
|
-
this.__line.start = startPoint;
|
|
153
|
-
this.__line.end = p;
|
|
154
|
-
|
|
155
|
-
const dots = this.__line.initPoints();
|
|
156
|
-
shapePoints = shapePoints.concat(dots);
|
|
157
|
-
}
|
|
158
|
-
return shapePoints;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 生成图例
|
|
163
|
-
*
|
|
164
|
-
* @method createLegend
|
|
165
|
-
*/
|
|
166
|
-
createLegend() {
|
|
167
|
-
|
|
168
|
-
//生成图例前的图标
|
|
169
|
-
var style = this.graph.utils.clone(this.style);
|
|
170
|
-
style.stroke = style.color;
|
|
171
|
-
var shape = this.graph.createShape('path',{style:style});
|
|
172
|
-
|
|
173
|
-
if(this.curve || this.style.curve) {
|
|
174
|
-
var p1 = {x:0,y: this.graph.style.legend.item.shape.height};
|
|
175
|
-
var p2 = {x:this.graph.style.legend.item.shape.width / 3,y:this.graph.style.legend.item.shape.height/3};
|
|
176
|
-
var p3 = {x:this.graph.style.legend.item.shape.width / 3 * 2,y:this.graph.style.legend.item.shape.height/3*2};
|
|
177
|
-
var p4 = {x:this.graph.style.legend.item.shape.width,y:0};
|
|
178
|
-
|
|
179
|
-
this.__bezier = this.__bezier || this.graph.createShape('bezier');
|
|
180
|
-
this.__bezier.cpoints = [
|
|
181
|
-
p1,p2,p3,p4
|
|
182
|
-
];//设置控制点
|
|
183
|
-
|
|
184
|
-
shape.points = this.__bezier.initPoints();
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
shape.points = [{
|
|
188
|
-
x:0,y: this.graph.style.legend.item.shape.height/2
|
|
189
|
-
},{
|
|
190
|
-
x: this.graph.style.legend.item.shape.width,y: this.graph.style.legend.item.shape.height/2
|
|
191
|
-
}];
|
|
192
|
-
}
|
|
193
|
-
this.graph.legend.append(this, shape);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// 生成布效果
|
|
197
|
-
createArea(points, needClosePoint = true) {
|
|
198
|
-
// 有指定绘制区域效果才展示
|
|
199
|
-
if(!this.style.area || points.length < 2) return;
|
|
200
|
-
|
|
201
|
-
const start = points[0];
|
|
202
|
-
const end = points[points.length - 1];
|
|
203
|
-
|
|
204
|
-
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
205
|
-
// 连框颜色如果没指定,就透明
|
|
206
|
-
style.stroke = style.stroke || 'transparent';
|
|
207
|
-
|
|
208
|
-
if(!style.fill) {
|
|
209
|
-
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
210
|
-
style.fill = `linear-gradient(50% 0 50% 100%,
|
|
211
|
-
rgba(${color.r},${color.g},${color.b}, 0) 1,
|
|
212
|
-
rgba(${color.r},${color.g},${color.b}, 0.1) 0.7,
|
|
213
|
-
rgba(${color.r},${color.g},${color.b}, 0.3) 0)`;
|
|
214
|
-
}
|
|
215
|
-
else if(typeof style.fill === 'function') {
|
|
216
|
-
style.fill = style.fill.call(this, style);
|
|
217
|
-
}
|
|
218
|
-
const area = this.graph.createShape('path', {
|
|
219
|
-
points: this.graph.utils.clone(points, true),
|
|
220
|
-
style,
|
|
221
|
-
width: this.graph.chartArea.width,
|
|
222
|
-
height: this.graph.chartArea.height
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// 在点集合前后加上落地到X轴的点就可以组成一个封闭的图形area
|
|
226
|
-
if(needClosePoint) {
|
|
227
|
-
area.points.unshift({
|
|
228
|
-
x: start.x,
|
|
229
|
-
y: this.baseY
|
|
230
|
-
});
|
|
231
|
-
area.points.push({
|
|
232
|
-
x: end.x,
|
|
233
|
-
y: this.baseY
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
this.addShape(area);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export {
|
|
242
|
-
jmLineSeries
|
|
243
|
-
}
|
|
1
|
+
|
|
2
|
+
import jmSeries from './series.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 图形基类
|
|
6
|
+
*
|
|
7
|
+
* @class jmLineSeries
|
|
8
|
+
* @module jmChart
|
|
9
|
+
* @param {jmChart} chart 当前图表
|
|
10
|
+
* @param {array} mappings 图形字段映射
|
|
11
|
+
* @param {style} style 样式
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
//构造函数
|
|
15
|
+
export default class jmLineSeries extends jmSeries {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
options.style = options.style || options.graph.style.line;
|
|
18
|
+
super(options);
|
|
19
|
+
|
|
20
|
+
//this.on('beginDraw', this[PreDrawKey]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 绘制图形前 初始化线条
|
|
25
|
+
*
|
|
26
|
+
* @method preDraw
|
|
27
|
+
* @for jmLineSeries
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
//生成描点位
|
|
31
|
+
const {
|
|
32
|
+
points,
|
|
33
|
+
dataChanged
|
|
34
|
+
} = this.initDataPoint();
|
|
35
|
+
|
|
36
|
+
//去除多余的线条
|
|
37
|
+
//当数据源线条数比现有的少时,删除多余的线条
|
|
38
|
+
const len = points.length;
|
|
39
|
+
|
|
40
|
+
//设定其填充颜色
|
|
41
|
+
//if(!this.style.fill) this.style.fill = jmUtils.toColor(this.style.stroke,null,null,20);
|
|
42
|
+
this.style.stroke = this.style.color;
|
|
43
|
+
//是否启用动画效果
|
|
44
|
+
//var ani = typeof this.enableAnimate === 'undefined'? this.graph.enableAnimate: this.enableAnimate;
|
|
45
|
+
this.style.item.stroke = this.style.color;
|
|
46
|
+
|
|
47
|
+
// 是否正在动画中
|
|
48
|
+
// 如果数据点多于100 个,暂时不启用动画,太慢了
|
|
49
|
+
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0 );
|
|
50
|
+
|
|
51
|
+
let shapePoints = []; // 计算出来的曲线点集合
|
|
52
|
+
const aniCount = (this.style.aniCount || 10);
|
|
53
|
+
const aniStep = Math.floor(len / aniCount) || 1;// 每次动画播放点个数
|
|
54
|
+
|
|
55
|
+
for(let i=0; i< len;i++) {
|
|
56
|
+
const p = points[i];
|
|
57
|
+
|
|
58
|
+
//如果当前点无效,则跳致下一点
|
|
59
|
+
if(typeof p.y === 'undefined' || p.y === null) {
|
|
60
|
+
//prePoint = null;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if(isRunningAni) {
|
|
65
|
+
if(i > this.___animateCounter) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 是否显示数值点圆
|
|
71
|
+
if(this.style.showItem) {
|
|
72
|
+
this.createPointItem(p);
|
|
73
|
+
}
|
|
74
|
+
// 平滑曲线
|
|
75
|
+
if(this.style.curve) {
|
|
76
|
+
shapePoints = this.createCurePoints(shapePoints, p);
|
|
77
|
+
}
|
|
78
|
+
// 如果是虚线
|
|
79
|
+
else if(this.style.lineType === 'dotted') {
|
|
80
|
+
shapePoints = this.createDotLine(shapePoints, p);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
shapePoints.push(p);
|
|
84
|
+
|
|
85
|
+
this.createItemLabel(p);
|
|
86
|
+
|
|
87
|
+
// 生成关健值标注
|
|
88
|
+
this.emit('onPointCreated', p);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 如果所有都已经结束,则重置成初始化状态
|
|
92
|
+
if(this.___animateCounter >= len - 1) {
|
|
93
|
+
this.___animateCounter = 0;
|
|
94
|
+
}
|
|
95
|
+
else if(isRunningAni) {
|
|
96
|
+
this.___animateCounter += aniStep;
|
|
97
|
+
// next tick 再次刷新
|
|
98
|
+
setTimeout(()=>{
|
|
99
|
+
this.needUpdate = true;//需要刷新
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.points = shapePoints;
|
|
104
|
+
this.createArea(shapePoints);// 仓建区域效果
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 生成点的小圆圈
|
|
108
|
+
createPointItem(p) {
|
|
109
|
+
const pointShape = this.graph.createShape('circle', {
|
|
110
|
+
style: this.style.item,
|
|
111
|
+
center: p,
|
|
112
|
+
radius: this.style.radius || 3
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
pointShape.zIndex = (pointShape.style.zIndex || 1) + 1;
|
|
116
|
+
return this.addShape(pointShape);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 根据上下点生成平滑曲线
|
|
120
|
+
createCurePoints(shapePoints, p) {
|
|
121
|
+
const startPoint = shapePoints[shapePoints.length - 1];
|
|
122
|
+
if(startPoint && startPoint.y != undefined && startPoint.y != null) {
|
|
123
|
+
//如果需要画曲线,则计算贝塞尔曲线坐标
|
|
124
|
+
const p1 = {x: startPoint.x + (p.x - startPoint.x) / 5, y: startPoint.y};
|
|
125
|
+
const p2 = {x: startPoint.x + (p.x - startPoint.x) / 2, y: p.y - (p.y - startPoint.y) / 2};
|
|
126
|
+
const p3 = {x: p.x - (p.x - startPoint.x) / 5, y: p.y};
|
|
127
|
+
|
|
128
|
+
//圆滑线条使用的贝塞尔对象
|
|
129
|
+
this.__bezier = this.__bezier || this.graph.createShape('bezier');
|
|
130
|
+
this.__bezier.cpoints = [
|
|
131
|
+
startPoint,
|
|
132
|
+
p1,
|
|
133
|
+
p2,
|
|
134
|
+
p3,
|
|
135
|
+
p
|
|
136
|
+
];//设置控制点
|
|
137
|
+
|
|
138
|
+
const bzpoints = this.__bezier.initPoints();
|
|
139
|
+
shapePoints = shapePoints.concat(bzpoints);
|
|
140
|
+
}
|
|
141
|
+
return shapePoints;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 生成虚线
|
|
145
|
+
createDotLine(shapePoints, p) {
|
|
146
|
+
const startPoint = shapePoints[shapePoints.length - 1];
|
|
147
|
+
if(startPoint && startPoint.y != undefined && startPoint.y != null) {
|
|
148
|
+
//使用线条来画虚线效果
|
|
149
|
+
this.__line = this.__line || this.graph.createShape('line', {
|
|
150
|
+
style: this.style,
|
|
151
|
+
});
|
|
152
|
+
this.__line.start = startPoint;
|
|
153
|
+
this.__line.end = p;
|
|
154
|
+
|
|
155
|
+
const dots = this.__line.initPoints();
|
|
156
|
+
shapePoints = shapePoints.concat(dots);
|
|
157
|
+
}
|
|
158
|
+
return shapePoints;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 生成图例
|
|
163
|
+
*
|
|
164
|
+
* @method createLegend
|
|
165
|
+
*/
|
|
166
|
+
createLegend() {
|
|
167
|
+
|
|
168
|
+
//生成图例前的图标
|
|
169
|
+
var style = this.graph.utils.clone(this.style);
|
|
170
|
+
style.stroke = style.color;
|
|
171
|
+
var shape = this.graph.createShape('path',{style:style});
|
|
172
|
+
|
|
173
|
+
if(this.curve || this.style.curve) {
|
|
174
|
+
var p1 = {x:0,y: this.graph.style.legend.item.shape.height};
|
|
175
|
+
var p2 = {x:this.graph.style.legend.item.shape.width / 3,y:this.graph.style.legend.item.shape.height/3};
|
|
176
|
+
var p3 = {x:this.graph.style.legend.item.shape.width / 3 * 2,y:this.graph.style.legend.item.shape.height/3*2};
|
|
177
|
+
var p4 = {x:this.graph.style.legend.item.shape.width,y:0};
|
|
178
|
+
|
|
179
|
+
this.__bezier = this.__bezier || this.graph.createShape('bezier');
|
|
180
|
+
this.__bezier.cpoints = [
|
|
181
|
+
p1,p2,p3,p4
|
|
182
|
+
];//设置控制点
|
|
183
|
+
|
|
184
|
+
shape.points = this.__bezier.initPoints();
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
shape.points = [{
|
|
188
|
+
x:0,y: this.graph.style.legend.item.shape.height/2
|
|
189
|
+
},{
|
|
190
|
+
x: this.graph.style.legend.item.shape.width,y: this.graph.style.legend.item.shape.height/2
|
|
191
|
+
}];
|
|
192
|
+
}
|
|
193
|
+
this.graph.legend.append(this, shape);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 生成布效果
|
|
197
|
+
createArea(points, needClosePoint = true) {
|
|
198
|
+
// 有指定绘制区域效果才展示
|
|
199
|
+
if(!this.style.area || points.length < 2) return;
|
|
200
|
+
|
|
201
|
+
const start = points[0];
|
|
202
|
+
const end = points[points.length - 1];
|
|
203
|
+
|
|
204
|
+
const style = this.graph.utils.clone(this.style.area, {}, true);
|
|
205
|
+
// 连框颜色如果没指定,就透明
|
|
206
|
+
style.stroke = style.stroke || 'transparent';
|
|
207
|
+
|
|
208
|
+
if(!style.fill) {
|
|
209
|
+
const color = this.graph.utils.hexToRGBA(this.style.stroke);
|
|
210
|
+
style.fill = `linear-gradient(50% 0 50% 100%,
|
|
211
|
+
rgba(${color.r},${color.g},${color.b}, 0) 1,
|
|
212
|
+
rgba(${color.r},${color.g},${color.b}, 0.1) 0.7,
|
|
213
|
+
rgba(${color.r},${color.g},${color.b}, 0.3) 0)`;
|
|
214
|
+
}
|
|
215
|
+
else if(typeof style.fill === 'function') {
|
|
216
|
+
style.fill = style.fill.call(this, style);
|
|
217
|
+
}
|
|
218
|
+
const area = this.graph.createShape('path', {
|
|
219
|
+
points: this.graph.utils.clone(points, true),
|
|
220
|
+
style,
|
|
221
|
+
width: this.graph.chartArea.width,
|
|
222
|
+
height: this.graph.chartArea.height
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// 在点集合前后加上落地到X轴的点就可以组成一个封闭的图形area
|
|
226
|
+
if(needClosePoint) {
|
|
227
|
+
area.points.unshift({
|
|
228
|
+
x: start.x,
|
|
229
|
+
y: this.baseY
|
|
230
|
+
});
|
|
231
|
+
area.points.push({
|
|
232
|
+
x: end.x,
|
|
233
|
+
y: this.baseY
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
this.addShape(area);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
jmLineSeries
|
|
243
|
+
}
|