jmchart 1.1.81 → 1.1.90
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 +680 -423
- package/dist/jmchart.cjs.js +678 -421
- package/dist/jmchart.esm.js +677 -420
- package/dist/jmchart.iife.js +679 -422
- package/dist/jmchart.system.js +682 -425
- package/example/bar.html +180 -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 +40 -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 +45 -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 +152 -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/dist/jmchart.esm.js
CHANGED
|
@@ -871,6 +871,23 @@ class jmUtils {
|
|
|
871
871
|
}
|
|
872
872
|
return r;
|
|
873
873
|
}
|
|
874
|
+
// window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
|
|
875
|
+
static requestAnimationFrame(callback) {
|
|
876
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
877
|
+
return setTimeout(callback, 20);
|
|
878
|
+
}
|
|
879
|
+
else {
|
|
880
|
+
return requestAnimationFrame(callback);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
static cancelAnimationFrame(handler) {
|
|
884
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
885
|
+
return clearTimeout(handler);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
return cancelAnimationFrame(handler);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
874
891
|
}
|
|
875
892
|
|
|
876
893
|
/**
|
|
@@ -4336,6 +4353,7 @@ class jmEvents {
|
|
|
4336
4353
|
|
|
4337
4354
|
touchStart(evt) {
|
|
4338
4355
|
evt = evt || window.event;
|
|
4356
|
+
evt.eventName = 'touchstart';
|
|
4339
4357
|
this.container.raiseEvent('touchstart',evt);
|
|
4340
4358
|
let t = evt.target || evt.srcElement;
|
|
4341
4359
|
if(t == this.target) {
|
|
@@ -4346,6 +4364,7 @@ class jmEvents {
|
|
|
4346
4364
|
|
|
4347
4365
|
touchMove(evt) {
|
|
4348
4366
|
evt = evt || window.event;
|
|
4367
|
+
evt.eventName = 'touchmove';
|
|
4349
4368
|
this.container.raiseEvent('touchmove',evt);
|
|
4350
4369
|
let t = evt.target || evt.srcElement;
|
|
4351
4370
|
if(t == this.target) {
|
|
@@ -4356,6 +4375,7 @@ class jmEvents {
|
|
|
4356
4375
|
|
|
4357
4376
|
touchEnd(evt) {
|
|
4358
4377
|
evt = evt || window.event;
|
|
4378
|
+
evt.eventName = 'touchend';
|
|
4359
4379
|
|
|
4360
4380
|
this.container.raiseEvent('touchend',evt);
|
|
4361
4381
|
let t = evt.target || evt.srcElement;
|
|
@@ -4367,6 +4387,7 @@ class jmEvents {
|
|
|
4367
4387
|
|
|
4368
4388
|
touchCancel(evt) {
|
|
4369
4389
|
evt = evt || window.event;
|
|
4390
|
+
evt.eventName = 'touchcancel';
|
|
4370
4391
|
|
|
4371
4392
|
this.container.raiseEvent('touchcancel',evt);
|
|
4372
4393
|
let t = evt.target || evt.srcElement;
|
|
@@ -4407,6 +4428,7 @@ class jmMouseEvent {
|
|
|
4407
4428
|
|
|
4408
4429
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousedown',function(evt) {
|
|
4409
4430
|
evt = evt || window.event;
|
|
4431
|
+
evt.eventName = 'mousedown';
|
|
4410
4432
|
container.raiseEvent('mousedown',evt);
|
|
4411
4433
|
//if(r === false) {
|
|
4412
4434
|
//if(evt.preventDefault) evt.preventDefault();
|
|
@@ -4416,6 +4438,7 @@ class jmMouseEvent {
|
|
|
4416
4438
|
|
|
4417
4439
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousemove',function(evt) {
|
|
4418
4440
|
evt = evt || window.event;
|
|
4441
|
+
evt.eventName = 'mousemove';
|
|
4419
4442
|
let target = evt.target || evt.srcElement;
|
|
4420
4443
|
if(target == canvas) {
|
|
4421
4444
|
container.raiseEvent('mousemove',evt);
|
|
@@ -4427,19 +4450,23 @@ class jmMouseEvent {
|
|
|
4427
4450
|
});
|
|
4428
4451
|
|
|
4429
4452
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mouseover',function(evt) {
|
|
4430
|
-
evt = evt || window.event;
|
|
4453
|
+
evt = evt || window.event;
|
|
4454
|
+
evt.eventName = 'mouseover';
|
|
4431
4455
|
container.raiseEvent('mouseover',evt);
|
|
4432
4456
|
});
|
|
4433
4457
|
this.eventEvents['mouseleave'] = jmUtils.bindEvent(this.target,'mouseleave',function(evt) {
|
|
4434
|
-
evt = evt || window.event;
|
|
4458
|
+
evt = evt || window.event;
|
|
4459
|
+
evt.eventName = 'mouseleave';
|
|
4435
4460
|
container.raiseEvent('mouseleave',evt);
|
|
4436
4461
|
});
|
|
4437
4462
|
this.eventEvents['mouseout'] = jmUtils.bindEvent(this.target,'mouseout',function(evt) {
|
|
4438
|
-
evt = evt || window.event;
|
|
4463
|
+
evt = evt || window.event;
|
|
4464
|
+
evt.eventName = 'mouseout';
|
|
4439
4465
|
container.raiseEvent('mouseout',evt);
|
|
4440
4466
|
});
|
|
4441
4467
|
doc && (this.eventEvents['mouseup'] = jmUtils.bindEvent(doc,'mouseup',function(evt) {
|
|
4442
|
-
evt = evt || window.event;
|
|
4468
|
+
evt = evt || window.event;
|
|
4469
|
+
evt.eventName = 'mouseup';
|
|
4443
4470
|
//let target = evt.target || evt.srcElement;
|
|
4444
4471
|
//if(target == canvas) {
|
|
4445
4472
|
let r = container.raiseEvent('mouseup',evt);
|
|
@@ -4452,33 +4479,40 @@ class jmMouseEvent {
|
|
|
4452
4479
|
|
|
4453
4480
|
this.eventEvents['dblclick'] = jmUtils.bindEvent(this.target,'dblclick',function(evt) {
|
|
4454
4481
|
evt = evt || window.event;
|
|
4482
|
+
evt.eventName = 'dblclick';
|
|
4455
4483
|
container.raiseEvent('dblclick',evt);
|
|
4456
4484
|
});
|
|
4457
4485
|
this.eventEvents['click'] = jmUtils.bindEvent(this.target,'click',function(evt) {
|
|
4458
4486
|
evt = evt || window.event;
|
|
4487
|
+
evt.eventName = 'click';
|
|
4459
4488
|
container.raiseEvent('click',evt);
|
|
4460
4489
|
});
|
|
4461
4490
|
|
|
4462
4491
|
doc && (this.eventEvents['resize'] = jmUtils.bindEvent(doc,'resize',function(evt) {
|
|
4463
4492
|
evt = evt || window.event;
|
|
4493
|
+
evt.eventName = 'resize';
|
|
4464
4494
|
return container.raiseEvent('resize',evt);
|
|
4465
4495
|
}));
|
|
4466
4496
|
|
|
4467
4497
|
// passive: false 为了让浏览器不告警并且preventDefault有效
|
|
4468
4498
|
// 另一种处理:touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。
|
|
4469
4499
|
this.eventEvents['touchstart'] = jmUtils.bindEvent(this.target,'touchstart', function(evt) {
|
|
4500
|
+
evt.eventName = 'touchstart';
|
|
4470
4501
|
return instance.touchStart(evt);
|
|
4471
4502
|
},{ passive: false });
|
|
4472
4503
|
|
|
4473
4504
|
this.eventEvents['touchmove'] = jmUtils.bindEvent(this.target,'touchmove', function(evt) {
|
|
4505
|
+
evt.eventName = 'touchmove';
|
|
4474
4506
|
return instance.touchMove(evt);
|
|
4475
4507
|
},{ passive: false });
|
|
4476
4508
|
|
|
4477
4509
|
doc && (this.eventEvents['touchend'] = jmUtils.bindEvent(doc,'touchend', function(evt) {
|
|
4510
|
+
evt.eventName = 'touchend';
|
|
4478
4511
|
return instance.touchEnd(evt);
|
|
4479
4512
|
},{ passive: false }));
|
|
4480
4513
|
|
|
4481
4514
|
doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'touchcancel', function(evt) {
|
|
4515
|
+
evt.eventName = 'touchcancel';
|
|
4482
4516
|
return instance.touchCancel(evt);
|
|
4483
4517
|
},{ passive: false }));
|
|
4484
4518
|
}
|
|
@@ -4533,7 +4567,7 @@ class jmKeyEvent {
|
|
|
4533
4567
|
return true;
|
|
4534
4568
|
};
|
|
4535
4569
|
|
|
4536
|
-
doc && (this.eventEvents['
|
|
4570
|
+
doc && (this.eventEvents['keypress'] = jmUtils.bindEvent(doc,'keypress',function(evt) {
|
|
4537
4571
|
evt = evt || window.event;
|
|
4538
4572
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4539
4573
|
let r = container.raiseEvent('keypress',evt);
|
|
@@ -4541,7 +4575,7 @@ class jmKeyEvent {
|
|
|
4541
4575
|
evt.preventDefault();
|
|
4542
4576
|
return r;
|
|
4543
4577
|
}));
|
|
4544
|
-
doc && (this.eventEvents['
|
|
4578
|
+
doc && (this.eventEvents['keydown'] = jmUtils.bindEvent(doc,'keydown',function(evt) {
|
|
4545
4579
|
evt = evt || window.event;
|
|
4546
4580
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4547
4581
|
let r = container.raiseEvent('keydown',evt);
|
|
@@ -4549,7 +4583,7 @@ class jmKeyEvent {
|
|
|
4549
4583
|
evt.preventDefault();
|
|
4550
4584
|
return r;
|
|
4551
4585
|
}));
|
|
4552
|
-
doc && (this.eventEvents['
|
|
4586
|
+
doc && (this.eventEvents['keyup'] = jmUtils.bindEvent(doc,'keyup',function(evt) {
|
|
4553
4587
|
evt = evt || window.event;
|
|
4554
4588
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4555
4589
|
let r = container.raiseEvent('keyup',evt);
|
|
@@ -5058,26 +5092,19 @@ class jmGraph$1 extends jmControl {
|
|
|
5058
5092
|
if(this.___isAutoRefreshing) return;
|
|
5059
5093
|
const self = this;
|
|
5060
5094
|
this.___isAutoRefreshing = true;
|
|
5061
|
-
|
|
5062
|
-
if(typeof requestAnimationFrame === 'undefined') {
|
|
5063
|
-
requestAnimationFrameFun = (fun) => {
|
|
5064
|
-
if(this.__requestAnimationFrameFunHandler) clearTimeout(this.__requestAnimationFrameFunHandler);
|
|
5065
|
-
this.__requestAnimationFrameFunHandler = setTimeout(fun, 20);
|
|
5066
|
-
};
|
|
5067
|
-
}
|
|
5068
|
-
else {
|
|
5069
|
-
requestAnimationFrameFun = requestAnimationFrame;
|
|
5070
|
-
}
|
|
5095
|
+
|
|
5071
5096
|
function update() {
|
|
5072
5097
|
if(self.destoryed) {
|
|
5073
5098
|
self.___isAutoRefreshing = false;
|
|
5074
5099
|
return;// 已销毁
|
|
5075
5100
|
}
|
|
5076
5101
|
if(self.needUpdate) self.redraw();
|
|
5077
|
-
|
|
5102
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5103
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5078
5104
|
if(callback) callback();
|
|
5079
5105
|
}
|
|
5080
|
-
|
|
5106
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5107
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5081
5108
|
return this;
|
|
5082
5109
|
}
|
|
5083
5110
|
|
|
@@ -5130,12 +5157,12 @@ class jmGraph extends jmGraph$1 {
|
|
|
5130
5157
|
}
|
|
5131
5158
|
}
|
|
5132
5159
|
|
|
5133
|
-
/**
|
|
5134
|
-
* 基础样式
|
|
5135
|
-
*
|
|
5136
|
-
* @class jmChartStyle
|
|
5137
|
-
* @module jmChart
|
|
5138
|
-
* @static
|
|
5160
|
+
/**
|
|
5161
|
+
* 基础样式
|
|
5162
|
+
*
|
|
5163
|
+
* @class jmChartStyle
|
|
5164
|
+
* @module jmChart
|
|
5165
|
+
* @static
|
|
5139
5166
|
*/
|
|
5140
5167
|
var defaultStyle = {
|
|
5141
5168
|
layout: 'normal',
|
|
@@ -5271,13 +5298,13 @@ var defaultStyle = {
|
|
|
5271
5298
|
// 图形样式集
|
|
5272
5299
|
chartColors: ['#249FDA', '#EA3B7C', '#8EBC00', '#309B46', '#4B507E', '#D8E404', '#EB792A', '#A00DA0'],
|
|
5273
5300
|
|
|
5274
|
-
/*tooltip: {
|
|
5275
|
-
'background-color': 'rgb(255,255,255)',
|
|
5276
|
-
'padding':'4px',
|
|
5277
|
-
'opacity':'0.8',
|
|
5278
|
-
'border':'1px solid #000',
|
|
5279
|
-
'box-shadow': '0 0 3px #000',
|
|
5280
|
-
'border-radius': '6px'
|
|
5301
|
+
/*tooltip: {
|
|
5302
|
+
'background-color': 'rgb(255,255,255)',
|
|
5303
|
+
'padding':'4px',
|
|
5304
|
+
'opacity':'0.8',
|
|
5305
|
+
'border':'1px solid #000',
|
|
5306
|
+
'box-shadow': '0 0 3px #000',
|
|
5307
|
+
'border-radius': '6px'
|
|
5281
5308
|
},*/
|
|
5282
5309
|
line: {
|
|
5283
5310
|
normal: {
|
|
@@ -5384,18 +5411,35 @@ var defaultStyle = {
|
|
|
5384
5411
|
blur: 2,
|
|
5385
5412
|
color: '#ccc'
|
|
5386
5413
|
}
|
|
5414
|
+
},
|
|
5415
|
+
candlestick: {
|
|
5416
|
+
normal: {
|
|
5417
|
+
lineWidth: 1,
|
|
5418
|
+
zIndex: 18,
|
|
5419
|
+
cursor: 'default'
|
|
5420
|
+
},
|
|
5421
|
+
hover: {
|
|
5422
|
+
//zIndex: 100,
|
|
5423
|
+
cursor: 'pointer'
|
|
5424
|
+
},
|
|
5425
|
+
perWidth: 0.5,
|
|
5426
|
+
// 阴线颜色
|
|
5427
|
+
negativeColor: 'green',
|
|
5428
|
+
// 阳线颜色
|
|
5429
|
+
masculineColor: 'red',
|
|
5430
|
+
lineWidth: 1
|
|
5387
5431
|
}
|
|
5388
5432
|
};
|
|
5389
5433
|
|
|
5390
|
-
/**
|
|
5391
|
-
* 轴
|
|
5392
|
-
*
|
|
5393
|
-
* @class jmAxis
|
|
5394
|
-
* @module jmChart
|
|
5395
|
-
* @param {jmChart} chart 当前图表
|
|
5396
|
-
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
5397
|
-
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
5398
|
-
* @param {object} [style] 样式
|
|
5434
|
+
/**
|
|
5435
|
+
* 轴
|
|
5436
|
+
*
|
|
5437
|
+
* @class jmAxis
|
|
5438
|
+
* @module jmChart
|
|
5439
|
+
* @param {jmChart} chart 当前图表
|
|
5440
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
5441
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
5442
|
+
* @param {object} [style] 样式
|
|
5399
5443
|
*/
|
|
5400
5444
|
|
|
5401
5445
|
class jmAxis extends jmArrowLine {
|
|
@@ -5442,21 +5486,21 @@ class jmAxis extends jmArrowLine {
|
|
|
5442
5486
|
|
|
5443
5487
|
if (typeof options.minXValue !== 'undefined') this.minValue = options.minXValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5444
5488
|
} else {
|
|
5445
|
-
if (typeof options.maxYValue !== 'undefined') this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
5489
|
+
if (typeof options.maxYValue !== 'undefined' && (options.maxYValue > this.maxValue || typeof this.maxValue === 'undefined')) this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
5446
5490
|
|
|
5447
|
-
if (typeof options.minYValue !== 'undefined') this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5491
|
+
if (typeof options.minYValue !== 'undefined' && (options.minYValue < this.minValue || typeof this.minValue === 'undefined')) this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5448
5492
|
}
|
|
5449
5493
|
}
|
|
5450
|
-
/**
|
|
5451
|
-
* 轴类型(x/y/radar),默认为x
|
|
5452
|
-
*
|
|
5453
|
-
* @property type
|
|
5454
|
-
* @type string
|
|
5494
|
+
/**
|
|
5495
|
+
* 轴类型(x/y/radar),默认为x
|
|
5496
|
+
*
|
|
5497
|
+
* @property type
|
|
5498
|
+
* @type string
|
|
5455
5499
|
*/
|
|
5456
5500
|
|
|
5457
5501
|
|
|
5458
|
-
/**
|
|
5459
|
-
* 关联访问的是chart的数据源
|
|
5502
|
+
/**
|
|
5503
|
+
* 关联访问的是chart的数据源
|
|
5460
5504
|
*/
|
|
5461
5505
|
get data() {
|
|
5462
5506
|
return this.graph.data;
|
|
@@ -5465,10 +5509,10 @@ class jmAxis extends jmArrowLine {
|
|
|
5465
5509
|
set data(d) {
|
|
5466
5510
|
this.graph.data = d;
|
|
5467
5511
|
}
|
|
5468
|
-
/**
|
|
5469
|
-
* 计算当前轴的位置
|
|
5470
|
-
*
|
|
5471
|
-
* @method reset
|
|
5512
|
+
/**
|
|
5513
|
+
* 计算当前轴的位置
|
|
5514
|
+
*
|
|
5515
|
+
* @method reset
|
|
5472
5516
|
*/
|
|
5473
5517
|
|
|
5474
5518
|
|
|
@@ -5526,10 +5570,10 @@ class jmAxis extends jmArrowLine {
|
|
|
5526
5570
|
|
|
5527
5571
|
super.draw();
|
|
5528
5572
|
}
|
|
5529
|
-
/**
|
|
5530
|
-
* 生成轴标签
|
|
5531
|
-
*
|
|
5532
|
-
* @method createLabel
|
|
5573
|
+
/**
|
|
5574
|
+
* 生成轴标签
|
|
5575
|
+
*
|
|
5576
|
+
* @method createLabel
|
|
5533
5577
|
*/
|
|
5534
5578
|
|
|
5535
5579
|
|
|
@@ -5546,11 +5590,11 @@ class jmAxis extends jmArrowLine {
|
|
|
5546
5590
|
this.createYLabel();
|
|
5547
5591
|
}
|
|
5548
5592
|
}
|
|
5549
|
-
/**
|
|
5550
|
-
* 生成X轴标签
|
|
5551
|
-
*
|
|
5552
|
-
* @method createXLabel
|
|
5553
|
-
* @private
|
|
5593
|
+
/**
|
|
5594
|
+
* 生成X轴标签
|
|
5595
|
+
*
|
|
5596
|
+
* @method createXLabel
|
|
5597
|
+
* @private
|
|
5554
5598
|
*/
|
|
5555
5599
|
|
|
5556
5600
|
|
|
@@ -5641,11 +5685,11 @@ class jmAxis extends jmArrowLine {
|
|
|
5641
5685
|
}
|
|
5642
5686
|
}
|
|
5643
5687
|
}
|
|
5644
|
-
/**
|
|
5645
|
-
* 生成Y轴标签
|
|
5646
|
-
*
|
|
5647
|
-
* @method createYLabel
|
|
5648
|
-
* @private
|
|
5688
|
+
/**
|
|
5689
|
+
* 生成Y轴标签
|
|
5690
|
+
*
|
|
5691
|
+
* @method createYLabel
|
|
5692
|
+
* @private
|
|
5649
5693
|
*/
|
|
5650
5694
|
|
|
5651
5695
|
|
|
@@ -5658,8 +5702,8 @@ class jmAxis extends jmArrowLine {
|
|
|
5658
5702
|
|
|
5659
5703
|
let count = this.labelCount;
|
|
5660
5704
|
const mm = max - min;
|
|
5661
|
-
/*if(mm <= 10) {
|
|
5662
|
-
count = mm;
|
|
5705
|
+
/*if(mm <= 10) {
|
|
5706
|
+
count = mm;
|
|
5663
5707
|
}*/
|
|
5664
5708
|
// mm 放大10000倍,这里结果也需要除于10000
|
|
5665
5709
|
|
|
@@ -5771,10 +5815,10 @@ class jmAxis extends jmArrowLine {
|
|
|
5771
5815
|
}
|
|
5772
5816
|
}
|
|
5773
5817
|
}
|
|
5774
|
-
/**
|
|
5775
|
-
* 获取当前轴所占宽
|
|
5776
|
-
*
|
|
5777
|
-
* @method width
|
|
5818
|
+
/**
|
|
5819
|
+
* 获取当前轴所占宽
|
|
5820
|
+
*
|
|
5821
|
+
* @method width
|
|
5778
5822
|
*/
|
|
5779
5823
|
|
|
5780
5824
|
|
|
@@ -5789,10 +5833,10 @@ class jmAxis extends jmArrowLine {
|
|
|
5789
5833
|
set width(w) {
|
|
5790
5834
|
this._width = w;
|
|
5791
5835
|
}
|
|
5792
|
-
/**
|
|
5793
|
-
* 获取当前轴所占高
|
|
5794
|
-
*
|
|
5795
|
-
* @method height
|
|
5836
|
+
/**
|
|
5837
|
+
* 获取当前轴所占高
|
|
5838
|
+
*
|
|
5839
|
+
* @method height
|
|
5796
5840
|
*/
|
|
5797
5841
|
|
|
5798
5842
|
|
|
@@ -5802,12 +5846,12 @@ class jmAxis extends jmArrowLine {
|
|
|
5802
5846
|
|
|
5803
5847
|
|
|
5804
5848
|
set height(h) {}
|
|
5805
|
-
/**
|
|
5806
|
-
* 获取或设置当前轴最大值
|
|
5807
|
-
*
|
|
5808
|
-
* @method max
|
|
5809
|
-
* @param {number/date/string} 当前轴的最大值
|
|
5810
|
-
* @return 当前轴的最大值
|
|
5849
|
+
/**
|
|
5850
|
+
* 获取或设置当前轴最大值
|
|
5851
|
+
*
|
|
5852
|
+
* @method max
|
|
5853
|
+
* @param {number/date/string} 当前轴的最大值
|
|
5854
|
+
* @return 当前轴的最大值
|
|
5811
5855
|
*/
|
|
5812
5856
|
|
|
5813
5857
|
|
|
@@ -5856,12 +5900,12 @@ class jmAxis extends jmArrowLine {
|
|
|
5856
5900
|
|
|
5857
5901
|
return this._max;
|
|
5858
5902
|
}
|
|
5859
|
-
/**
|
|
5860
|
-
* 获取或设置当前轴最小值
|
|
5861
|
-
*
|
|
5862
|
-
* @method max
|
|
5863
|
-
* @param {number/date/string} 当前轴的最小值
|
|
5864
|
-
* @return 当前轴的最小值
|
|
5903
|
+
/**
|
|
5904
|
+
* 获取或设置当前轴最小值
|
|
5905
|
+
*
|
|
5906
|
+
* @method max
|
|
5907
|
+
* @param {number/date/string} 当前轴的最小值
|
|
5908
|
+
* @return 当前轴的最小值
|
|
5865
5909
|
*/
|
|
5866
5910
|
|
|
5867
5911
|
|
|
@@ -5908,10 +5952,10 @@ class jmAxis extends jmArrowLine {
|
|
|
5908
5952
|
|
|
5909
5953
|
return this.dataType == 'string' ? 0 : this._min;
|
|
5910
5954
|
}
|
|
5911
|
-
/**
|
|
5912
|
-
* 清除一些属性
|
|
5913
|
-
*
|
|
5914
|
-
* @method clear
|
|
5955
|
+
/**
|
|
5956
|
+
* 清除一些属性
|
|
5957
|
+
*
|
|
5958
|
+
* @method clear
|
|
5915
5959
|
*/
|
|
5916
5960
|
|
|
5917
5961
|
|
|
@@ -5919,11 +5963,11 @@ class jmAxis extends jmArrowLine {
|
|
|
5919
5963
|
this._min = null;
|
|
5920
5964
|
this._max = null;
|
|
5921
5965
|
}
|
|
5922
|
-
/**
|
|
5923
|
-
* 计算当前轴的单位偏移量
|
|
5924
|
-
*
|
|
5925
|
-
* @method step
|
|
5926
|
-
* @return {number} 单位偏移量
|
|
5966
|
+
/**
|
|
5967
|
+
* 计算当前轴的单位偏移量
|
|
5968
|
+
*
|
|
5969
|
+
* @method step
|
|
5970
|
+
* @return {number} 单位偏移量
|
|
5927
5971
|
*/
|
|
5928
5972
|
|
|
5929
5973
|
|
|
@@ -5972,12 +6016,12 @@ class jmAxis extends jmArrowLine {
|
|
|
5972
6016
|
|
|
5973
6017
|
}
|
|
5974
6018
|
|
|
5975
|
-
/**
|
|
5976
|
-
* 图例的容器
|
|
5977
|
-
*
|
|
5978
|
-
* @class jmLegend
|
|
5979
|
-
* @module jmChart
|
|
5980
|
-
* @param {jmChart} chart 当前图表
|
|
6019
|
+
/**
|
|
6020
|
+
* 图例的容器
|
|
6021
|
+
*
|
|
6022
|
+
* @class jmLegend
|
|
6023
|
+
* @module jmChart
|
|
6024
|
+
* @param {jmChart} chart 当前图表
|
|
5981
6025
|
*/
|
|
5982
6026
|
|
|
5983
6027
|
class jmLegend extends jmRect {
|
|
@@ -5989,20 +6033,20 @@ class jmLegend extends jmRect {
|
|
|
5989
6033
|
};
|
|
5990
6034
|
super(options);
|
|
5991
6035
|
|
|
5992
|
-
_defineProperty(this, "legendPosition", '
|
|
6036
|
+
_defineProperty(this, "legendPosition", '');
|
|
5993
6037
|
}
|
|
5994
|
-
/**
|
|
5995
|
-
* 图例放置位置
|
|
6038
|
+
/**
|
|
6039
|
+
* 图例放置位置
|
|
5996
6040
|
*/
|
|
5997
6041
|
|
|
5998
6042
|
|
|
5999
6043
|
}
|
|
6000
|
-
/**
|
|
6001
|
-
* 添加图例
|
|
6002
|
-
*
|
|
6003
|
-
* @method append
|
|
6004
|
-
* @param {jmSeries} series 当前图序列
|
|
6005
|
-
* @param {jmControl} shape 当前图例的图形对象
|
|
6044
|
+
/**
|
|
6045
|
+
* 添加图例
|
|
6046
|
+
*
|
|
6047
|
+
* @method append
|
|
6048
|
+
* @param {jmSeries} series 当前图序列
|
|
6049
|
+
* @param {jmControl} shape 当前图例的图形对象
|
|
6006
6050
|
*/
|
|
6007
6051
|
|
|
6008
6052
|
jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
@@ -6042,24 +6086,27 @@ jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
|
6042
6086
|
panel.height = shape.height; //执行进入事件
|
|
6043
6087
|
//触动图例后加粗显示图
|
|
6044
6088
|
|
|
6045
|
-
/*const hover = options.hover || function() {
|
|
6046
|
-
//应用图的动态样式
|
|
6047
|
-
//Object.assign(series.style, series.style.hover);
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
//
|
|
6058
|
-
|
|
6059
|
-
|
|
6089
|
+
/*const hover = options.hover || function() {
|
|
6090
|
+
//应用图的动态样式
|
|
6091
|
+
//Object.assign(series.style, series.style.hover);
|
|
6092
|
+
|
|
6093
|
+
//Object.assign(this.style, this.style.hover || {});
|
|
6094
|
+
|
|
6095
|
+
//series.graph.refresh();
|
|
6096
|
+
};
|
|
6097
|
+
panel.bind('mouseover', hover);
|
|
6098
|
+
//执行离开
|
|
6099
|
+
const leave = options.leave || function() {
|
|
6100
|
+
//应用图的普通样式
|
|
6101
|
+
//Object.assign(series.style, series.style.normal);
|
|
6102
|
+
|
|
6103
|
+
//Object.assign(this.style, this.style.normal || {});
|
|
6104
|
+
//jmUtils.apply(this.series.style.normal,this.series.style);
|
|
6105
|
+
//series.graph.refresh();
|
|
6106
|
+
};
|
|
6060
6107
|
panel.bind('mouseleave', leave);*/
|
|
6061
6108
|
|
|
6062
|
-
const legendPosition = this.legendPosition || this.style.legendPosition;
|
|
6109
|
+
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
6063
6110
|
|
|
6064
6111
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6065
6112
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
@@ -6076,10 +6123,10 @@ jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
|
6076
6123
|
|
|
6077
6124
|
this.needUpdate = true;
|
|
6078
6125
|
};
|
|
6079
|
-
/**
|
|
6080
|
-
* 初始化图例
|
|
6081
|
-
*
|
|
6082
|
-
* @method init
|
|
6126
|
+
/**
|
|
6127
|
+
* 初始化图例
|
|
6128
|
+
*
|
|
6129
|
+
* @method init
|
|
6083
6130
|
*/
|
|
6084
6131
|
|
|
6085
6132
|
|
|
@@ -6091,10 +6138,10 @@ jmLegend.prototype.init = function () {
|
|
|
6091
6138
|
this.style.lineWidth = 0;
|
|
6092
6139
|
this.children.clear();
|
|
6093
6140
|
};
|
|
6094
|
-
/**
|
|
6095
|
-
* 重置图例属性,根据图例内容计算期大小并更新画图区域大小
|
|
6096
|
-
*
|
|
6097
|
-
* @method reset
|
|
6141
|
+
/**
|
|
6142
|
+
* 重置图例属性,根据图例内容计算期大小并更新画图区域大小
|
|
6143
|
+
*
|
|
6144
|
+
* @method reset
|
|
6098
6145
|
*/
|
|
6099
6146
|
|
|
6100
6147
|
|
|
@@ -6139,11 +6186,11 @@ jmLegend.prototype.reset = function () {
|
|
|
6139
6186
|
};
|
|
6140
6187
|
|
|
6141
6188
|
var utils = {
|
|
6142
|
-
/**
|
|
6143
|
-
* 对比二个数组数据是否改变
|
|
6144
|
-
* @param {Array} source 被对比的数、组
|
|
6145
|
-
* @param {Array} target 对比数组
|
|
6146
|
-
* @param {Function} compare 比较函数
|
|
6189
|
+
/**
|
|
6190
|
+
* 对比二个数组数据是否改变
|
|
6191
|
+
* @param {Array} source 被对比的数、组
|
|
6192
|
+
* @param {Array} target 对比数组
|
|
6193
|
+
* @param {Function} compare 比较函数
|
|
6147
6194
|
*/
|
|
6148
6195
|
arrayIsChange(source, target, compare) {
|
|
6149
6196
|
if (!source || !target) return true;
|
|
@@ -6160,14 +6207,14 @@ var utils = {
|
|
|
6160
6207
|
|
|
6161
6208
|
};
|
|
6162
6209
|
|
|
6163
|
-
/**
|
|
6164
|
-
* 图形基类
|
|
6165
|
-
*
|
|
6166
|
-
* @class jmSeries
|
|
6167
|
-
* @module jmChart
|
|
6168
|
-
* @param {jmChart} chart 当前图表
|
|
6169
|
-
* @param {array} mappings 图形字段映射
|
|
6170
|
-
* @param {style} style 样式
|
|
6210
|
+
/**
|
|
6211
|
+
* 图形基类
|
|
6212
|
+
*
|
|
6213
|
+
* @class jmSeries
|
|
6214
|
+
* @module jmChart
|
|
6215
|
+
* @param {jmChart} chart 当前图表
|
|
6216
|
+
* @param {array} mappings 图形字段映射
|
|
6217
|
+
* @param {style} style 样式
|
|
6171
6218
|
*/
|
|
6172
6219
|
//构造线图
|
|
6173
6220
|
|
|
@@ -6211,8 +6258,8 @@ class jmSeries extends jmPath {
|
|
|
6211
6258
|
maxYValue: options.maxYValue
|
|
6212
6259
|
});
|
|
6213
6260
|
}
|
|
6214
|
-
/**
|
|
6215
|
-
* 关联访问的是chart的数据源
|
|
6261
|
+
/**
|
|
6262
|
+
* 关联访问的是chart的数据源
|
|
6216
6263
|
*/
|
|
6217
6264
|
|
|
6218
6265
|
|
|
@@ -6234,11 +6281,11 @@ class jmSeries extends jmPath {
|
|
|
6234
6281
|
set enableAnimate(v) {
|
|
6235
6282
|
this.option.enableAnimate = v;
|
|
6236
6283
|
}
|
|
6237
|
-
/**
|
|
6238
|
-
* 图例名称
|
|
6239
|
-
*
|
|
6240
|
-
* @property legendLabel
|
|
6241
|
-
* @type string
|
|
6284
|
+
/**
|
|
6285
|
+
* 图例名称
|
|
6286
|
+
*
|
|
6287
|
+
* @property legendLabel
|
|
6288
|
+
* @type string
|
|
6242
6289
|
*/
|
|
6243
6290
|
|
|
6244
6291
|
|
|
@@ -6268,10 +6315,10 @@ class jmSeries extends jmPath {
|
|
|
6268
6315
|
points: this.dataPoints
|
|
6269
6316
|
};
|
|
6270
6317
|
}
|
|
6271
|
-
/**
|
|
6272
|
-
* 根据X轴坐标,获取它最近的数据描点
|
|
6273
|
-
* 离点最近的一个描点
|
|
6274
|
-
* @param {number} x X轴坐标
|
|
6318
|
+
/**
|
|
6319
|
+
* 根据X轴坐标,获取它最近的数据描点
|
|
6320
|
+
* 离点最近的一个描点
|
|
6321
|
+
* @param {number} x X轴坐标
|
|
6275
6322
|
*/
|
|
6276
6323
|
|
|
6277
6324
|
|
|
@@ -6299,9 +6346,9 @@ class jmSeries extends jmPath {
|
|
|
6299
6346
|
|
|
6300
6347
|
return null;
|
|
6301
6348
|
}
|
|
6302
|
-
/**
|
|
6303
|
-
* 根据X轴值获取数据点
|
|
6304
|
-
* @param {number} xValue X轴值
|
|
6349
|
+
/**
|
|
6350
|
+
* 根据X轴值获取数据点
|
|
6351
|
+
* @param {number} xValue X轴值
|
|
6305
6352
|
*/
|
|
6306
6353
|
|
|
6307
6354
|
|
|
@@ -6315,11 +6362,11 @@ class jmSeries extends jmPath {
|
|
|
6315
6362
|
|
|
6316
6363
|
return null;
|
|
6317
6364
|
}
|
|
6318
|
-
/**
|
|
6319
|
-
* 重置属性
|
|
6320
|
-
* 根据数据源计算轴的属性
|
|
6321
|
-
*
|
|
6322
|
-
* @method reset
|
|
6365
|
+
/**
|
|
6366
|
+
* 重置属性
|
|
6367
|
+
* 根据数据源计算轴的属性
|
|
6368
|
+
*
|
|
6369
|
+
* @method reset
|
|
6323
6370
|
*/
|
|
6324
6371
|
|
|
6325
6372
|
|
|
@@ -6363,10 +6410,10 @@ class jmSeries extends jmPath {
|
|
|
6363
6410
|
this.xAxis.min(xv);
|
|
6364
6411
|
}
|
|
6365
6412
|
}
|
|
6366
|
-
/**
|
|
6367
|
-
* 生成序列图描点
|
|
6368
|
-
*
|
|
6369
|
-
* @method createPoints
|
|
6413
|
+
/**
|
|
6414
|
+
* 生成序列图描点
|
|
6415
|
+
*
|
|
6416
|
+
* @method createPoints
|
|
6370
6417
|
*/
|
|
6371
6418
|
|
|
6372
6419
|
|
|
@@ -6408,7 +6455,8 @@ class jmSeries extends jmPath {
|
|
|
6408
6455
|
x: p.x,
|
|
6409
6456
|
// 高度
|
|
6410
6457
|
height: p.height,
|
|
6411
|
-
yValue: yv
|
|
6458
|
+
yValue: yv,
|
|
6459
|
+
field: f
|
|
6412
6460
|
}; //如果Y值不存在。则此点无效,不画图
|
|
6413
6461
|
|
|
6414
6462
|
if (yv == null || typeof yv == 'undefined') {
|
|
@@ -6443,10 +6491,10 @@ class jmSeries extends jmPath {
|
|
|
6443
6491
|
return this.style.color;
|
|
6444
6492
|
}
|
|
6445
6493
|
}
|
|
6446
|
-
/**
|
|
6447
|
-
* 生成图例
|
|
6448
|
-
*
|
|
6449
|
-
* @method createLegend
|
|
6494
|
+
/**
|
|
6495
|
+
* 生成图例
|
|
6496
|
+
*
|
|
6497
|
+
* @method createLegend
|
|
6450
6498
|
*/
|
|
6451
6499
|
|
|
6452
6500
|
|
|
@@ -6498,9 +6546,9 @@ class jmSeries extends jmPath {
|
|
|
6498
6546
|
});
|
|
6499
6547
|
this.addShape(label);
|
|
6500
6548
|
}
|
|
6501
|
-
/**
|
|
6502
|
-
* 在图上加下定制图形
|
|
6503
|
-
* @param {jmShape} shape 图形
|
|
6549
|
+
/**
|
|
6550
|
+
* 在图上加下定制图形
|
|
6551
|
+
* @param {jmShape} shape 图形
|
|
6504
6552
|
*/
|
|
6505
6553
|
|
|
6506
6554
|
|
|
@@ -6509,13 +6557,13 @@ class jmSeries extends jmPath {
|
|
|
6509
6557
|
this.shapes.add(shape);
|
|
6510
6558
|
return shape;
|
|
6511
6559
|
}
|
|
6512
|
-
/**
|
|
6513
|
-
* 获取指定事件的集合
|
|
6514
|
-
* 比如mousedown,mouseup等
|
|
6515
|
-
*
|
|
6516
|
-
* @method getEvent
|
|
6517
|
-
* @param {string} name 事件名称
|
|
6518
|
-
* @return {list} 事件委托的集合
|
|
6560
|
+
/**
|
|
6561
|
+
* 获取指定事件的集合
|
|
6562
|
+
* 比如mousedown,mouseup等
|
|
6563
|
+
*
|
|
6564
|
+
* @method getEvent
|
|
6565
|
+
* @param {string} name 事件名称
|
|
6566
|
+
* @return {list} 事件委托的集合
|
|
6519
6567
|
*/
|
|
6520
6568
|
|
|
6521
6569
|
|
|
@@ -6539,14 +6587,14 @@ class jmSeries extends jmPath {
|
|
|
6539
6587
|
|
|
6540
6588
|
}
|
|
6541
6589
|
|
|
6542
|
-
/**
|
|
6543
|
-
* 柱图
|
|
6544
|
-
*
|
|
6545
|
-
* @class jmBarSeries
|
|
6546
|
-
* @module jmChart
|
|
6547
|
-
* @param {jmChart} chart 当前图表
|
|
6548
|
-
* @param {array} mappings 图形字段映射
|
|
6549
|
-
* @param {style} style 样式
|
|
6590
|
+
/**
|
|
6591
|
+
* 柱图
|
|
6592
|
+
*
|
|
6593
|
+
* @class jmBarSeries
|
|
6594
|
+
* @module jmChart
|
|
6595
|
+
* @param {jmChart} chart 当前图表
|
|
6596
|
+
* @param {array} mappings 图形字段映射
|
|
6597
|
+
* @param {style} style 样式
|
|
6550
6598
|
*/
|
|
6551
6599
|
//构造函数
|
|
6552
6600
|
|
|
@@ -6554,11 +6602,11 @@ class jmBarSeries extends jmSeries {
|
|
|
6554
6602
|
constructor(options) {
|
|
6555
6603
|
super(options);
|
|
6556
6604
|
}
|
|
6557
|
-
/**
|
|
6558
|
-
* 绘制当前图形
|
|
6559
|
-
*
|
|
6560
|
-
* @method beginDraw
|
|
6561
|
-
* @for jmBarSeries
|
|
6605
|
+
/**
|
|
6606
|
+
* 绘制当前图形
|
|
6607
|
+
*
|
|
6608
|
+
* @method beginDraw
|
|
6609
|
+
* @for jmBarSeries
|
|
6562
6610
|
*/
|
|
6563
6611
|
|
|
6564
6612
|
|
|
@@ -6665,9 +6713,9 @@ class jmBarSeries extends jmSeries {
|
|
|
6665
6713
|
this.barTotalWidth = maxWidth * this.graph.barSeriesCount;
|
|
6666
6714
|
}
|
|
6667
6715
|
}
|
|
6668
|
-
/**
|
|
6669
|
-
* 在图上加下定制图形
|
|
6670
|
-
* @param {jmShape} shape 图形
|
|
6716
|
+
/**
|
|
6717
|
+
* 在图上加下定制图形
|
|
6718
|
+
* @param {jmShape} shape 图形
|
|
6671
6719
|
*/
|
|
6672
6720
|
|
|
6673
6721
|
|
|
@@ -6679,14 +6727,14 @@ class jmBarSeries extends jmSeries {
|
|
|
6679
6727
|
|
|
6680
6728
|
}
|
|
6681
6729
|
|
|
6682
|
-
/**
|
|
6683
|
-
* 柱图
|
|
6684
|
-
*
|
|
6685
|
-
* @class jmBarSeries
|
|
6686
|
-
* @module jmChart
|
|
6687
|
-
* @param {jmChart} chart 当前图表
|
|
6688
|
-
* @param {array} mappings 图形字段映射
|
|
6689
|
-
* @param {style} style 样式
|
|
6730
|
+
/**
|
|
6731
|
+
* 柱图
|
|
6732
|
+
*
|
|
6733
|
+
* @class jmBarSeries
|
|
6734
|
+
* @module jmChart
|
|
6735
|
+
* @param {jmChart} chart 当前图表
|
|
6736
|
+
* @param {array} mappings 图形字段映射
|
|
6737
|
+
* @param {style} style 样式
|
|
6690
6738
|
*/
|
|
6691
6739
|
//构造函数
|
|
6692
6740
|
|
|
@@ -6694,11 +6742,11 @@ class jmStackBarSeries extends jmBarSeries {
|
|
|
6694
6742
|
constructor(options) {
|
|
6695
6743
|
super(options);
|
|
6696
6744
|
}
|
|
6697
|
-
/**
|
|
6698
|
-
* 绘制当前图形
|
|
6699
|
-
*
|
|
6700
|
-
* @method beginDraw
|
|
6701
|
-
* @for jmBarSeries
|
|
6745
|
+
/**
|
|
6746
|
+
* 绘制当前图形
|
|
6747
|
+
*
|
|
6748
|
+
* @method beginDraw
|
|
6749
|
+
* @for jmBarSeries
|
|
6702
6750
|
*/
|
|
6703
6751
|
|
|
6704
6752
|
|
|
@@ -6828,14 +6876,14 @@ class jmStackBarSeries extends jmBarSeries {
|
|
|
6828
6876
|
|
|
6829
6877
|
}
|
|
6830
6878
|
|
|
6831
|
-
/**
|
|
6832
|
-
* 饼图
|
|
6833
|
-
*
|
|
6834
|
-
* @class jmPieSeries
|
|
6835
|
-
* @module jmChart
|
|
6836
|
-
* @param {jmChart} chart 当前图表
|
|
6837
|
-
* @param {array} mappings 图形字段映射
|
|
6838
|
-
* @param {style} style 样式
|
|
6879
|
+
/**
|
|
6880
|
+
* 饼图
|
|
6881
|
+
*
|
|
6882
|
+
* @class jmPieSeries
|
|
6883
|
+
* @module jmChart
|
|
6884
|
+
* @param {jmChart} chart 当前图表
|
|
6885
|
+
* @param {array} mappings 图形字段映射
|
|
6886
|
+
* @param {style} style 样式
|
|
6839
6887
|
*/
|
|
6840
6888
|
//构造函数
|
|
6841
6889
|
|
|
@@ -6919,10 +6967,10 @@ class jmPieSeries extends jmSeries {
|
|
|
6919
6967
|
set startAngle(v) {
|
|
6920
6968
|
this.option.startAngle = v;
|
|
6921
6969
|
}
|
|
6922
|
-
/**
|
|
6923
|
-
* 生成序列图描点
|
|
6924
|
-
*
|
|
6925
|
-
* @method createPoints
|
|
6970
|
+
/**
|
|
6971
|
+
* 生成序列图描点
|
|
6972
|
+
*
|
|
6973
|
+
* @method createPoints
|
|
6926
6974
|
*/
|
|
6927
6975
|
|
|
6928
6976
|
|
|
@@ -7012,8 +7060,8 @@ class jmPieSeries extends jmSeries {
|
|
|
7012
7060
|
maxRadius: p.maxRadius,
|
|
7013
7061
|
minRadius: p.minRadius
|
|
7014
7062
|
});
|
|
7015
|
-
/**
|
|
7016
|
-
* 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
|
|
7063
|
+
/**
|
|
7064
|
+
* 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
|
|
7017
7065
|
*/
|
|
7018
7066
|
|
|
7019
7067
|
p.shape.getLocation = function () {
|
|
@@ -7122,10 +7170,10 @@ class jmPieSeries extends jmSeries {
|
|
|
7122
7170
|
}
|
|
7123
7171
|
|
|
7124
7172
|
}
|
|
7125
|
-
/**
|
|
7126
|
-
* 生成图例
|
|
7127
|
-
*
|
|
7128
|
-
* @method createLegend
|
|
7173
|
+
/**
|
|
7174
|
+
* 生成图例
|
|
7175
|
+
*
|
|
7176
|
+
* @method createLegend
|
|
7129
7177
|
*/
|
|
7130
7178
|
|
|
7131
7179
|
jmPieSeries.prototype.createLegend = function () {
|
|
@@ -7167,14 +7215,14 @@ jmPieSeries.prototype.createLegend = function () {
|
|
|
7167
7215
|
}
|
|
7168
7216
|
};
|
|
7169
7217
|
|
|
7170
|
-
/**
|
|
7171
|
-
* 图形基类
|
|
7172
|
-
*
|
|
7173
|
-
* @class jmLineSeries
|
|
7174
|
-
* @module jmChart
|
|
7175
|
-
* @param {jmChart} chart 当前图表
|
|
7176
|
-
* @param {array} mappings 图形字段映射
|
|
7177
|
-
* @param {style} style 样式
|
|
7218
|
+
/**
|
|
7219
|
+
* 图形基类
|
|
7220
|
+
*
|
|
7221
|
+
* @class jmLineSeries
|
|
7222
|
+
* @module jmChart
|
|
7223
|
+
* @param {jmChart} chart 当前图表
|
|
7224
|
+
* @param {array} mappings 图形字段映射
|
|
7225
|
+
* @param {style} style 样式
|
|
7178
7226
|
*/
|
|
7179
7227
|
//构造函数
|
|
7180
7228
|
|
|
@@ -7183,11 +7231,11 @@ class jmLineSeries extends jmSeries {
|
|
|
7183
7231
|
options.style = options.style || options.graph.style.line;
|
|
7184
7232
|
super(options); //this.on('beginDraw', this[PreDrawKey]);
|
|
7185
7233
|
}
|
|
7186
|
-
/**
|
|
7187
|
-
* 绘制图形前 初始化线条
|
|
7188
|
-
*
|
|
7189
|
-
* @method preDraw
|
|
7190
|
-
* @for jmLineSeries
|
|
7234
|
+
/**
|
|
7235
|
+
* 绘制图形前 初始化线条
|
|
7236
|
+
*
|
|
7237
|
+
* @method preDraw
|
|
7238
|
+
* @for jmLineSeries
|
|
7191
7239
|
*/
|
|
7192
7240
|
|
|
7193
7241
|
|
|
@@ -7322,10 +7370,10 @@ class jmLineSeries extends jmSeries {
|
|
|
7322
7370
|
|
|
7323
7371
|
return shapePoints;
|
|
7324
7372
|
}
|
|
7325
|
-
/**
|
|
7326
|
-
* 生成图例
|
|
7327
|
-
*
|
|
7328
|
-
* @method createLegend
|
|
7373
|
+
/**
|
|
7374
|
+
* 生成图例
|
|
7375
|
+
*
|
|
7376
|
+
* @method createLegend
|
|
7329
7377
|
*/
|
|
7330
7378
|
|
|
7331
7379
|
|
|
@@ -7414,14 +7462,14 @@ class jmLineSeries extends jmSeries {
|
|
|
7414
7462
|
|
|
7415
7463
|
}
|
|
7416
7464
|
|
|
7417
|
-
/**
|
|
7418
|
-
* 二条线组成的区域图表
|
|
7419
|
-
*
|
|
7420
|
-
* @class jmStackLineSeries
|
|
7421
|
-
* @module jmChart
|
|
7422
|
-
* @param {jmChart} chart 当前图表
|
|
7423
|
-
* @param {array} mappings 图形字段映射
|
|
7424
|
-
* @param {style} style 样式
|
|
7465
|
+
/**
|
|
7466
|
+
* 二条线组成的区域图表
|
|
7467
|
+
*
|
|
7468
|
+
* @class jmStackLineSeries
|
|
7469
|
+
* @module jmChart
|
|
7470
|
+
* @param {jmChart} chart 当前图表
|
|
7471
|
+
* @param {array} mappings 图形字段映射
|
|
7472
|
+
* @param {style} style 样式
|
|
7425
7473
|
*/
|
|
7426
7474
|
//构造函数
|
|
7427
7475
|
|
|
@@ -7430,11 +7478,11 @@ class jmStackLineSeries extends jmLineSeries {
|
|
|
7430
7478
|
options.style = options.style || options.graph.style.stackLine;
|
|
7431
7479
|
super(options);
|
|
7432
7480
|
}
|
|
7433
|
-
/**
|
|
7434
|
-
* 绘制图形前 初始化线条
|
|
7435
|
-
*
|
|
7436
|
-
* @method preDraw
|
|
7437
|
-
* @for jmLineSeries
|
|
7481
|
+
/**
|
|
7482
|
+
* 绘制图形前 初始化线条
|
|
7483
|
+
*
|
|
7484
|
+
* @method preDraw
|
|
7485
|
+
* @for jmLineSeries
|
|
7438
7486
|
*/
|
|
7439
7487
|
|
|
7440
7488
|
|
|
@@ -7514,10 +7562,10 @@ class jmStackLineSeries extends jmLineSeries {
|
|
|
7514
7562
|
areaEnd.m = false;
|
|
7515
7563
|
this.createArea(areaPoints, false);
|
|
7516
7564
|
}
|
|
7517
|
-
/**
|
|
7518
|
-
* 生成图例
|
|
7519
|
-
*
|
|
7520
|
-
* @method createLegend
|
|
7565
|
+
/**
|
|
7566
|
+
* 生成图例
|
|
7567
|
+
*
|
|
7568
|
+
* @method createLegend
|
|
7521
7569
|
*/
|
|
7522
7570
|
|
|
7523
7571
|
|
|
@@ -7565,15 +7613,114 @@ class jmStackLineSeries extends jmLineSeries {
|
|
|
7565
7613
|
|
|
7566
7614
|
}
|
|
7567
7615
|
|
|
7568
|
-
/**
|
|
7569
|
-
*
|
|
7570
|
-
*
|
|
7571
|
-
* @class
|
|
7572
|
-
* @module jmChart
|
|
7573
|
-
* @param {jmChart} chart 当前图表
|
|
7574
|
-
* @param {
|
|
7575
|
-
* @param {
|
|
7576
|
-
|
|
7616
|
+
/**
|
|
7617
|
+
* K线图
|
|
7618
|
+
*
|
|
7619
|
+
* @class jmCandlestickSeries
|
|
7620
|
+
* @module jmChart
|
|
7621
|
+
* @param {jmChart} chart 当前图表
|
|
7622
|
+
* @param {array} mappings 图形字段映射
|
|
7623
|
+
* @param {style} style 样式
|
|
7624
|
+
*/
|
|
7625
|
+
//构造函数
|
|
7626
|
+
|
|
7627
|
+
class jmCandlestickSeries extends jmSeries {
|
|
7628
|
+
constructor(options) {
|
|
7629
|
+
options.style = options.style || options.graph.style.line;
|
|
7630
|
+
super(options); //this.on('beginDraw', this[PreDrawKey]);
|
|
7631
|
+
}
|
|
7632
|
+
/**
|
|
7633
|
+
* 绘制图形前 初始化线条
|
|
7634
|
+
*
|
|
7635
|
+
* @method preDraw
|
|
7636
|
+
* @for jmLineSeries
|
|
7637
|
+
*/
|
|
7638
|
+
|
|
7639
|
+
|
|
7640
|
+
init() {
|
|
7641
|
+
//生成描点位
|
|
7642
|
+
const {
|
|
7643
|
+
points
|
|
7644
|
+
} = this.initDataPoint(); //去除多余的线条
|
|
7645
|
+
//当数据源线条数比现有的少时,删除多余的线条
|
|
7646
|
+
|
|
7647
|
+
const len = points.length;
|
|
7648
|
+
this.initWidth(len);
|
|
7649
|
+
const w = this.barWidth / 2; //实心处宽度的一半
|
|
7650
|
+
|
|
7651
|
+
for (let i = 0; i < len; i++) {
|
|
7652
|
+
const p = points[i]; //如果当前点无效,则跳致下一点
|
|
7653
|
+
|
|
7654
|
+
if (typeof p.y === 'undefined' || p.y === null) {
|
|
7655
|
+
//prePoint = null;
|
|
7656
|
+
continue;
|
|
7657
|
+
}
|
|
7658
|
+
|
|
7659
|
+
const sp = this.addShape(this.graph.createPath([], p.style));
|
|
7660
|
+
const bl = {
|
|
7661
|
+
x: p.x - w,
|
|
7662
|
+
y: p.points[0].y
|
|
7663
|
+
};
|
|
7664
|
+
const br = {
|
|
7665
|
+
x: p.x + w,
|
|
7666
|
+
y: p.points[0].y
|
|
7667
|
+
};
|
|
7668
|
+
const tl = {
|
|
7669
|
+
x: p.x - w,
|
|
7670
|
+
y: p.points[1].y
|
|
7671
|
+
};
|
|
7672
|
+
const tr = {
|
|
7673
|
+
x: p.x + w,
|
|
7674
|
+
y: p.points[1].y
|
|
7675
|
+
}; // 默认认为是阳线
|
|
7676
|
+
|
|
7677
|
+
let tm = p.points[1];
|
|
7678
|
+
let bm = p.points[0];
|
|
7679
|
+
p.style.stroke = p.style.fill = p.style.masculineColor || 'red'; // 开盘大于收盘,则阴线
|
|
7680
|
+
|
|
7681
|
+
if (p.points[0].yValue > p.points[1].yValue) {
|
|
7682
|
+
p.style.stroke = p.style.fill = p.style.negativeColor || 'green';
|
|
7683
|
+
bl.y = br.y = p.points[1].y;
|
|
7684
|
+
tl.y = tr.y = p.points[0].y;
|
|
7685
|
+
tm = p.points[0];
|
|
7686
|
+
bm = p.points[1];
|
|
7687
|
+
}
|
|
7688
|
+
|
|
7689
|
+
sp.points.push(p.points[2], tm, tl, bl, bm, p.points[3], bm, br, tr, tm, p.points[2]); // 生成关健值标注
|
|
7690
|
+
|
|
7691
|
+
this.emit('onPointCreated', p);
|
|
7692
|
+
}
|
|
7693
|
+
} // 计算实心体宽度
|
|
7694
|
+
|
|
7695
|
+
|
|
7696
|
+
initWidth(count) {
|
|
7697
|
+
//计算每个柱子占宽
|
|
7698
|
+
//每项柱子占宽除以柱子个数,默认最大宽度为30
|
|
7699
|
+
const maxWidth = this.xAxis.width / count;
|
|
7700
|
+
|
|
7701
|
+
if (this.style.barWidth > 0) {
|
|
7702
|
+
this.barWidth = Number(this.style.barWidth);
|
|
7703
|
+
} else {
|
|
7704
|
+
this.barWidth = maxWidth * (this.style.perWidth || 0.4);
|
|
7705
|
+
}
|
|
7706
|
+
|
|
7707
|
+
if (this.barWidth > maxWidth) {
|
|
7708
|
+
this.barWidth = maxWidth;
|
|
7709
|
+
this.barTotalWidth = maxWidth * count;
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
|
|
7713
|
+
}
|
|
7714
|
+
|
|
7715
|
+
/**
|
|
7716
|
+
* 轴
|
|
7717
|
+
*
|
|
7718
|
+
* @class jmAxis
|
|
7719
|
+
* @module jmChart
|
|
7720
|
+
* @param {jmChart} chart 当前图表
|
|
7721
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
7722
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
7723
|
+
* @param {object} [style] 样式
|
|
7577
7724
|
*/
|
|
7578
7725
|
|
|
7579
7726
|
class jmMarkLine extends jmLine {
|
|
@@ -7582,8 +7729,8 @@ class jmMarkLine extends jmLine {
|
|
|
7582
7729
|
this.visible = false;
|
|
7583
7730
|
this.markLineType = options.type || 'x'; // 为横轴x或纵轴y
|
|
7584
7731
|
|
|
7585
|
-
/**
|
|
7586
|
-
* 当前图形下的所有子图
|
|
7732
|
+
/**
|
|
7733
|
+
* 当前图形下的所有子图
|
|
7587
7734
|
*/
|
|
7588
7735
|
|
|
7589
7736
|
this.shapes = new jmList();
|
|
@@ -7646,8 +7793,8 @@ class jmMarkLine extends jmLine {
|
|
|
7646
7793
|
serie.lastMarkPoint = point; // 记下最后一次改变的点
|
|
7647
7794
|
// 同时改变下X轴标线的位置,它的Y坐标跟随最后一个命中的线点
|
|
7648
7795
|
|
|
7649
|
-
if (graph && graph.xMarkLine) {
|
|
7650
|
-
graph.xMarkLine.start.y = graph.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
|
|
7796
|
+
if (graph && graph.markLine && graph.markLine.xMarkLine) {
|
|
7797
|
+
graph.markLine.xMarkLine.start.y = graph.markLine.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
|
|
7651
7798
|
}
|
|
7652
7799
|
}
|
|
7653
7800
|
} catch (e) {
|
|
@@ -7662,9 +7809,9 @@ class jmMarkLine extends jmLine {
|
|
|
7662
7809
|
}, 10);
|
|
7663
7810
|
}
|
|
7664
7811
|
}
|
|
7665
|
-
/**
|
|
7666
|
-
* 移动标线
|
|
7667
|
-
* @param { object } args 移动事件参数
|
|
7812
|
+
/**
|
|
7813
|
+
* 移动标线
|
|
7814
|
+
* @param { object } args 移动事件参数
|
|
7668
7815
|
*/
|
|
7669
7816
|
|
|
7670
7817
|
|
|
@@ -7728,8 +7875,8 @@ class jmMarkLine extends jmLine {
|
|
|
7728
7875
|
this.needUpdate = true;
|
|
7729
7876
|
}
|
|
7730
7877
|
}
|
|
7731
|
-
/**
|
|
7732
|
-
* 中止
|
|
7878
|
+
/**
|
|
7879
|
+
* 中止
|
|
7733
7880
|
*/
|
|
7734
7881
|
|
|
7735
7882
|
|
|
@@ -7740,13 +7887,170 @@ class jmMarkLine extends jmLine {
|
|
|
7740
7887
|
|
|
7741
7888
|
}
|
|
7742
7889
|
|
|
7743
|
-
/**
|
|
7744
|
-
*
|
|
7745
|
-
*
|
|
7746
|
-
*
|
|
7747
|
-
* @
|
|
7748
|
-
* @
|
|
7749
|
-
* @param {
|
|
7890
|
+
/**
|
|
7891
|
+
* 轴
|
|
7892
|
+
*
|
|
7893
|
+
* @class jmMarkLineManager
|
|
7894
|
+
* @module jmChart
|
|
7895
|
+
* @param {jmChart} chart 当前图表
|
|
7896
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
7897
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
7898
|
+
* @param {object} [style] 样式
|
|
7899
|
+
*/
|
|
7900
|
+
|
|
7901
|
+
class jmMarkLineManager {
|
|
7902
|
+
constructor(chart) {
|
|
7903
|
+
this.chart = chart;
|
|
7904
|
+
this.init(chart);
|
|
7905
|
+
} // 初始化
|
|
7906
|
+
|
|
7907
|
+
|
|
7908
|
+
init(chart) {
|
|
7909
|
+
const graph = chart.touchGraph || chart;
|
|
7910
|
+
graph.on('beginDraw', () => {
|
|
7911
|
+
// 重置标线,会处理小圆圈问题
|
|
7912
|
+
this.xMarkLine && this.xMarkLine.init();
|
|
7913
|
+
this.yMarkLine && this.yMarkLine.init();
|
|
7914
|
+
});
|
|
7915
|
+
|
|
7916
|
+
if (chart.style.markLine) {
|
|
7917
|
+
// 生成标线,可以跟随鼠标或手指滑动
|
|
7918
|
+
if (chart.style.markLine && chart.style.markLine.x) {
|
|
7919
|
+
this.xMarkLine = graph.createShape(jmMarkLine, {
|
|
7920
|
+
type: 'x',
|
|
7921
|
+
style: chart.style.markLine
|
|
7922
|
+
});
|
|
7923
|
+
const area = graph.chartArea || graph;
|
|
7924
|
+
area.children.add(this.xMarkLine);
|
|
7925
|
+
}
|
|
7926
|
+
|
|
7927
|
+
if (chart.style.markLine && chart.style.markLine.y) {
|
|
7928
|
+
this.yMarkLine = graph.createShape(jmMarkLine, {
|
|
7929
|
+
type: 'y',
|
|
7930
|
+
style: chart.style.markLine
|
|
7931
|
+
});
|
|
7932
|
+
const area = graph.chartArea || graph;
|
|
7933
|
+
area.children.add(this.yMarkLine);
|
|
7934
|
+
}
|
|
7935
|
+
|
|
7936
|
+
let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
|
|
7937
|
+
|
|
7938
|
+
let longtapHandler = 0;
|
|
7939
|
+
let touchStartPos = {
|
|
7940
|
+
x: 0,
|
|
7941
|
+
y: 0
|
|
7942
|
+
};
|
|
7943
|
+
graph.on('mousedown touchstart', args => {
|
|
7944
|
+
// 如果长按才启用
|
|
7945
|
+
if (chart.style.markLine.longtap) {
|
|
7946
|
+
longtap = 1;
|
|
7947
|
+
longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
|
|
7948
|
+
let tapStartTime = Date.now();
|
|
7949
|
+
|
|
7950
|
+
const reqFun = () => {
|
|
7951
|
+
const elapsed = Date.now() - tapStartTime;
|
|
7952
|
+
|
|
7953
|
+
if (longtap === 1 || longtap === 2) {
|
|
7954
|
+
// 如果还未过一定时间,则继续等待
|
|
7955
|
+
if (elapsed < 500) {
|
|
7956
|
+
longtapHandler = graph.utils.requestAnimationFrame(reqFun);
|
|
7957
|
+
return;
|
|
7958
|
+
}
|
|
7959
|
+
|
|
7960
|
+
longtap = 2;
|
|
7961
|
+
this.startMove(args);
|
|
7962
|
+
chart.emit('marklinelongtapstart', args);
|
|
7963
|
+
}
|
|
7964
|
+
}; // 如果一定时间后还没有取消,则表示长按了
|
|
7965
|
+
|
|
7966
|
+
|
|
7967
|
+
longtapHandler = graph.utils.requestAnimationFrame(reqFun); //args.event.stopPropagation();
|
|
7968
|
+
|
|
7969
|
+
args.event.preventDefault(); // 阻止默认行为
|
|
7970
|
+
} else {
|
|
7971
|
+
this.startMove(args);
|
|
7972
|
+
}
|
|
7973
|
+
|
|
7974
|
+
args.longtap = longtap;
|
|
7975
|
+
touchStartPos = args.position;
|
|
7976
|
+
}); // 移动标线
|
|
7977
|
+
|
|
7978
|
+
graph.on('mousemove touchmove', args => {
|
|
7979
|
+
const ox = args.position.x - touchStartPos.x;
|
|
7980
|
+
const oy = args.position.y - touchStartPos.y;
|
|
7981
|
+
const offpos = Math.sqrt(ox * ox + oy * oy);
|
|
7982
|
+
if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
|
|
7983
|
+
|
|
7984
|
+
args.longtap = longtap;
|
|
7985
|
+
this.move(args);
|
|
7986
|
+
}); // 取消移动
|
|
7987
|
+
|
|
7988
|
+
graph.on('mouseup touchend touchcancel touchleave', args => {
|
|
7989
|
+
longtap = 0;
|
|
7990
|
+
this.endMove(args);
|
|
7991
|
+
});
|
|
7992
|
+
}
|
|
7993
|
+
} // 开始移动标线
|
|
7994
|
+
|
|
7995
|
+
|
|
7996
|
+
startMove(args, markLineType = 'xy') {
|
|
7997
|
+
if (this.xMarkLine && markLineType.includes('x')) {
|
|
7998
|
+
this.xMarkLine.visible = true;
|
|
7999
|
+
this.xMarkLine.move(args);
|
|
8000
|
+
}
|
|
8001
|
+
|
|
8002
|
+
if (this.yMarkLine && markLineType.includes('y')) {
|
|
8003
|
+
this.yMarkLine.visible = true;
|
|
8004
|
+
this.yMarkLine.move(args);
|
|
8005
|
+
}
|
|
8006
|
+
|
|
8007
|
+
if (!args.cancel) this.chart.emit('marklinestartmove', args);
|
|
8008
|
+
} // 移动标线
|
|
8009
|
+
|
|
8010
|
+
|
|
8011
|
+
move(args) {
|
|
8012
|
+
let moved = false;
|
|
8013
|
+
|
|
8014
|
+
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
8015
|
+
this.xMarkLine.move(args);
|
|
8016
|
+
moved = true;
|
|
8017
|
+
}
|
|
8018
|
+
|
|
8019
|
+
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
8020
|
+
this.yMarkLine.move(args);
|
|
8021
|
+
moved = true;
|
|
8022
|
+
}
|
|
8023
|
+
|
|
8024
|
+
if (moved) {
|
|
8025
|
+
args.event.stopPropagation();
|
|
8026
|
+
args.event.preventDefault(); // 阻止默认行为
|
|
8027
|
+
|
|
8028
|
+
if (!args.cancel) this.chart.emit('marklinemove', args);
|
|
8029
|
+
}
|
|
8030
|
+
} // 终止动移
|
|
8031
|
+
|
|
8032
|
+
|
|
8033
|
+
endMove(args) {
|
|
8034
|
+
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
8035
|
+
this.xMarkLine.cancel(args);
|
|
8036
|
+
}
|
|
8037
|
+
|
|
8038
|
+
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
8039
|
+
this.yMarkLine.cancel(args);
|
|
8040
|
+
}
|
|
8041
|
+
|
|
8042
|
+
if (!args.cancel) this.chart.emit('marklineendmove', args);
|
|
8043
|
+
}
|
|
8044
|
+
|
|
8045
|
+
}
|
|
8046
|
+
|
|
8047
|
+
/**
|
|
8048
|
+
* jm图表组件
|
|
8049
|
+
* option参数:graph=jmgraph
|
|
8050
|
+
*
|
|
8051
|
+
* @class jmChart
|
|
8052
|
+
* @module jmChart
|
|
8053
|
+
* @param {element} container 图表容器
|
|
7750
8054
|
*/
|
|
7751
8055
|
|
|
7752
8056
|
class jmChart extends jmGraph {
|
|
@@ -7775,13 +8079,13 @@ class jmChart extends jmGraph {
|
|
|
7775
8079
|
|
|
7776
8080
|
this.createTouchGraph(this.container, options);
|
|
7777
8081
|
}
|
|
7778
|
-
/**
|
|
7779
|
-
* 绑定的数据源
|
|
8082
|
+
/**
|
|
8083
|
+
* 绑定的数据源
|
|
7780
8084
|
*/
|
|
7781
8085
|
|
|
7782
8086
|
|
|
7783
|
-
/**
|
|
7784
|
-
* 是否启用动画
|
|
8087
|
+
/**
|
|
8088
|
+
* 是否启用动画
|
|
7785
8089
|
*/
|
|
7786
8090
|
get enableAnimate() {
|
|
7787
8091
|
if (typeof this.option.enableAnimate !== 'undefined') return !!this.option.enableAnimate;else {
|
|
@@ -7792,8 +8096,8 @@ class jmChart extends jmGraph {
|
|
|
7792
8096
|
set enableAnimate(v) {
|
|
7793
8097
|
this.option.enableAnimate = v;
|
|
7794
8098
|
}
|
|
7795
|
-
/**
|
|
7796
|
-
* Y轴的基线 默认是0
|
|
8099
|
+
/**
|
|
8100
|
+
* Y轴的基线 默认是0
|
|
7797
8101
|
*/
|
|
7798
8102
|
|
|
7799
8103
|
|
|
@@ -7807,11 +8111,11 @@ class jmChart extends jmGraph {
|
|
|
7807
8111
|
|
|
7808
8112
|
|
|
7809
8113
|
init(options) {
|
|
7810
|
-
/**
|
|
7811
|
-
* 绘图区域
|
|
7812
|
-
*
|
|
7813
|
-
* @property chartArea
|
|
7814
|
-
* @type jmControl
|
|
8114
|
+
/**
|
|
8115
|
+
* 绘图区域
|
|
8116
|
+
*
|
|
8117
|
+
* @property chartArea
|
|
8118
|
+
* @type jmControl
|
|
7815
8119
|
*/
|
|
7816
8120
|
if (!this.chartArea) {
|
|
7817
8121
|
this.chartArea = this.createShape('rect', {
|
|
@@ -7823,11 +8127,11 @@ class jmChart extends jmGraph {
|
|
|
7823
8127
|
});
|
|
7824
8128
|
this.children.add(this.chartArea);
|
|
7825
8129
|
}
|
|
7826
|
-
/**
|
|
7827
|
-
* 图例
|
|
7828
|
-
*
|
|
7829
|
-
* @property legend
|
|
7830
|
-
* @type jmLegend
|
|
8130
|
+
/**
|
|
8131
|
+
* 图例
|
|
8132
|
+
*
|
|
8133
|
+
* @property legend
|
|
8134
|
+
* @type jmLegend
|
|
7831
8135
|
*/
|
|
7832
8136
|
|
|
7833
8137
|
|
|
@@ -7839,11 +8143,11 @@ class jmChart extends jmGraph {
|
|
|
7839
8143
|
if (options.legendVisible === false) {
|
|
7840
8144
|
this.legend.visible = false;
|
|
7841
8145
|
}
|
|
7842
|
-
/**
|
|
7843
|
-
* 图表提示控件
|
|
7844
|
-
*
|
|
7845
|
-
* @property tooltip
|
|
7846
|
-
* @type jmTooltip
|
|
8146
|
+
/**
|
|
8147
|
+
* 图表提示控件
|
|
8148
|
+
*
|
|
8149
|
+
* @property tooltip
|
|
8150
|
+
* @type jmTooltip
|
|
7847
8151
|
*/
|
|
7848
8152
|
//this.tooltip = this.graph.createShape('tooltip',{style:this.style.tooltip});
|
|
7849
8153
|
//this.chartArea.children.add(this.tooltip);
|
|
@@ -7861,84 +8165,36 @@ class jmChart extends jmGraph {
|
|
|
7861
8165
|
container && (container.style.position = 'relative');
|
|
7862
8166
|
options = this.utils.clone(options, {
|
|
7863
8167
|
autoRefresh: true
|
|
7864
|
-
}, true);
|
|
7865
|
-
let graph = this.touchGraph = this; // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
|
|
8168
|
+
}, true); // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
|
|
7866
8169
|
// isWXMiniApp 非微信小程序下才能创建
|
|
7867
8170
|
|
|
7868
|
-
if (!
|
|
8171
|
+
if (!this.isWXMiniApp && container && options.touchGraph) {
|
|
7869
8172
|
let cn = document.createElement('canvas');
|
|
7870
8173
|
cn.width = container.offsetWidth || container.clientWidth;
|
|
7871
8174
|
cn.height = container.offsetHeight || container.clientHeight;
|
|
7872
8175
|
cn.style.position = 'absolute';
|
|
7873
8176
|
cn.style.top = 0;
|
|
7874
8177
|
cn.style.left = 0;
|
|
7875
|
-
this.touchGraph =
|
|
8178
|
+
this.touchGraph = new jmGraph(cn, options);
|
|
7876
8179
|
container.appendChild(cn);
|
|
7877
8180
|
this.touchGraph.chartGraph = this;
|
|
7878
8181
|
this.on('propertyChange', (name, args) => {
|
|
7879
8182
|
if (['width', 'height'].includes(name)) {
|
|
7880
8183
|
this.touchGraph[name] = args.newValue / this.devicePixelRatio;
|
|
7881
8184
|
}
|
|
7882
|
-
});
|
|
7883
|
-
}
|
|
8185
|
+
}); // 把上层canvse事件传递给绘图层对象
|
|
7884
8186
|
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
// 重置标线,会处理小圆圈问题
|
|
7888
|
-
this.xMarkLine && this.xMarkLine.init();
|
|
7889
|
-
this.yMarkLine && this.yMarkLine.init();
|
|
7890
|
-
}); // 生成标线,可以跟随鼠标或手指滑动
|
|
8187
|
+
this.touchGraph.on('mousedown touchstart mousemove touchmove mouseup touchend touchcancel touchleave', args => {
|
|
8188
|
+
const eventName = args.event.eventName || args.event.type;
|
|
7891
8189
|
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
type: 'x',
|
|
7895
|
-
style: this.style.markLine
|
|
7896
|
-
});
|
|
7897
|
-
const area = graph.chartArea || graph;
|
|
7898
|
-
area.children.add(this.xMarkLine);
|
|
7899
|
-
}
|
|
7900
|
-
|
|
7901
|
-
if (this.style.markLine && this.style.markLine.y) {
|
|
7902
|
-
this.yMarkLine = graph.createShape(jmMarkLine, {
|
|
7903
|
-
type: 'y',
|
|
7904
|
-
style: this.style.markLine
|
|
7905
|
-
});
|
|
7906
|
-
const area = graph.chartArea || graph;
|
|
7907
|
-
area.children.add(this.yMarkLine);
|
|
7908
|
-
}
|
|
7909
|
-
|
|
7910
|
-
graph.on('mousedown touchstart', args => {
|
|
7911
|
-
if (this.xMarkLine) {
|
|
7912
|
-
this.xMarkLine.visible = true;
|
|
7913
|
-
this.xMarkLine.move(args);
|
|
7914
|
-
}
|
|
7915
|
-
|
|
7916
|
-
if (this.yMarkLine) {
|
|
7917
|
-
this.yMarkLine.visible = true;
|
|
7918
|
-
this.yMarkLine.move(args);
|
|
8190
|
+
if (eventName) {
|
|
8191
|
+
this.emit(eventName, args);
|
|
7919
8192
|
}
|
|
7920
|
-
});
|
|
7921
|
-
|
|
7922
|
-
graph.on('mousemove touchmove', args => {
|
|
7923
|
-
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
7924
|
-
this.xMarkLine.move(args);
|
|
7925
|
-
}
|
|
7926
|
-
|
|
7927
|
-
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
7928
|
-
this.yMarkLine.move(args);
|
|
7929
|
-
}
|
|
7930
|
-
}); // 取消移动
|
|
8193
|
+
});
|
|
8194
|
+
} // 初始化标线
|
|
7931
8195
|
|
|
7932
|
-
graph.on('mouseup touchend touchcancel touchleave', args => {
|
|
7933
|
-
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
7934
|
-
this.xMarkLine.cancel(args);
|
|
7935
|
-
}
|
|
7936
8196
|
|
|
7937
|
-
|
|
7938
|
-
this.yMarkLine.cancel(args);
|
|
7939
|
-
}
|
|
7940
|
-
});
|
|
7941
|
-
}
|
|
8197
|
+
this.markLine = new jmMarkLineManager(this);
|
|
7942
8198
|
} // 重置整个图表
|
|
7943
8199
|
|
|
7944
8200
|
|
|
@@ -7971,11 +8227,11 @@ class jmChart extends jmGraph {
|
|
|
7971
8227
|
delete this.yAxises;
|
|
7972
8228
|
}
|
|
7973
8229
|
}
|
|
7974
|
-
/**
|
|
7975
|
-
* 获取颜色
|
|
7976
|
-
*
|
|
7977
|
-
* @method getColor
|
|
7978
|
-
* @param {int} index 颜色索引
|
|
8230
|
+
/**
|
|
8231
|
+
* 获取颜色
|
|
8232
|
+
*
|
|
8233
|
+
* @method getColor
|
|
8234
|
+
* @param {int} index 颜色索引
|
|
7979
8235
|
*/
|
|
7980
8236
|
|
|
7981
8237
|
|
|
@@ -7987,11 +8243,11 @@ class jmChart extends jmGraph {
|
|
|
7987
8243
|
|
|
7988
8244
|
return this.style.chartColors[index];
|
|
7989
8245
|
}
|
|
7990
|
-
/**
|
|
7991
|
-
* 绘制当前图表
|
|
7992
|
-
* 先绘制轴等基础信息
|
|
7993
|
-
*
|
|
7994
|
-
* @method beginDraw
|
|
8246
|
+
/**
|
|
8247
|
+
* 绘制当前图表
|
|
8248
|
+
* 先绘制轴等基础信息
|
|
8249
|
+
*
|
|
8250
|
+
* @method beginDraw
|
|
7995
8251
|
*/
|
|
7996
8252
|
|
|
7997
8253
|
|
|
@@ -8056,10 +8312,10 @@ class jmChart extends jmGraph {
|
|
|
8056
8312
|
serie.init && serie.init();
|
|
8057
8313
|
}); //console.log('beginDraw4', Date.now() - startTime);
|
|
8058
8314
|
}
|
|
8059
|
-
/**
|
|
8060
|
-
* 重新定位区域的位置
|
|
8061
|
-
*
|
|
8062
|
-
* @method resetAreaPosition
|
|
8315
|
+
/**
|
|
8316
|
+
* 重新定位区域的位置
|
|
8317
|
+
*
|
|
8318
|
+
* @method resetAreaPosition
|
|
8063
8319
|
*/
|
|
8064
8320
|
|
|
8065
8321
|
|
|
@@ -8071,15 +8327,15 @@ class jmChart extends jmGraph {
|
|
|
8071
8327
|
this.chartArea.width = w;
|
|
8072
8328
|
this.chartArea.height = h;
|
|
8073
8329
|
}
|
|
8074
|
-
/**
|
|
8075
|
-
* 创建轴
|
|
8076
|
-
*
|
|
8077
|
-
* @method createAxis
|
|
8078
|
-
* @for jmChart
|
|
8079
|
-
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
8080
|
-
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
8081
|
-
* @param {object} [style] 样式
|
|
8082
|
-
* @return {axis} 轴
|
|
8330
|
+
/**
|
|
8331
|
+
* 创建轴
|
|
8332
|
+
*
|
|
8333
|
+
* @method createAxis
|
|
8334
|
+
* @for jmChart
|
|
8335
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
8336
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
8337
|
+
* @param {object} [style] 样式
|
|
8338
|
+
* @return {axis} 轴
|
|
8083
8339
|
*/
|
|
8084
8340
|
|
|
8085
8341
|
|
|
@@ -8091,12 +8347,12 @@ class jmChart extends jmGraph {
|
|
|
8091
8347
|
this.children.add(axis);
|
|
8092
8348
|
return axis;
|
|
8093
8349
|
}
|
|
8094
|
-
/**
|
|
8095
|
-
* 生成X轴
|
|
8096
|
-
*
|
|
8097
|
-
* @method createXAxis
|
|
8098
|
-
* @param {string} x轴的数据类型(string/number/date)
|
|
8099
|
-
* @param {bool} 是否从0开始
|
|
8350
|
+
/**
|
|
8351
|
+
* 生成X轴
|
|
8352
|
+
*
|
|
8353
|
+
* @method createXAxis
|
|
8354
|
+
* @param {string} x轴的数据类型(string/number/date)
|
|
8355
|
+
* @param {bool} 是否从0开始
|
|
8100
8356
|
*/
|
|
8101
8357
|
|
|
8102
8358
|
|
|
@@ -8123,13 +8379,13 @@ class jmChart extends jmGraph {
|
|
|
8123
8379
|
|
|
8124
8380
|
return this.xAxis;
|
|
8125
8381
|
}
|
|
8126
|
-
/**
|
|
8127
|
-
* 生成Y轴
|
|
8128
|
-
*
|
|
8129
|
-
* @method createYAxis
|
|
8130
|
-
* @param {int} Y轴索引,可以创建多个Y轴
|
|
8131
|
-
* @param {string} y轴的数据类型(string/number/date)
|
|
8132
|
-
* @param {bool} 是否从0开始
|
|
8382
|
+
/**
|
|
8383
|
+
* 生成Y轴
|
|
8384
|
+
*
|
|
8385
|
+
* @method createYAxis
|
|
8386
|
+
* @param {int} Y轴索引,可以创建多个Y轴
|
|
8387
|
+
* @param {string} y轴的数据类型(string/number/date)
|
|
8388
|
+
* @param {bool} 是否从0开始
|
|
8133
8389
|
*/
|
|
8134
8390
|
|
|
8135
8391
|
|
|
@@ -8158,14 +8414,14 @@ class jmChart extends jmGraph {
|
|
|
8158
8414
|
var yaxis = this.yAxises[options.index] || (this.yAxises[options.index] = this.createAxis(options));
|
|
8159
8415
|
return yaxis;
|
|
8160
8416
|
}
|
|
8161
|
-
/**
|
|
8162
|
-
* 创建图形
|
|
8163
|
-
*
|
|
8164
|
-
* @method createSeries
|
|
8165
|
-
* @for jmChart
|
|
8166
|
-
* @param {string} [type] 图类型,(line/bar/pie/radar)
|
|
8167
|
-
* @param {object} [options] 生成图表选项 {xField, yField, index}
|
|
8168
|
-
* @return {series} 图形
|
|
8417
|
+
/**
|
|
8418
|
+
* 创建图形
|
|
8419
|
+
*
|
|
8420
|
+
* @method createSeries
|
|
8421
|
+
* @for jmChart
|
|
8422
|
+
* @param {string} [type] 图类型,(line/bar/pie/radar)
|
|
8423
|
+
* @param {object} [options] 生成图表选项 {xField, yField, index}
|
|
8424
|
+
* @return {series} 图形
|
|
8169
8425
|
*/
|
|
8170
8426
|
|
|
8171
8427
|
|
|
@@ -8176,7 +8432,8 @@ class jmChart extends jmGraph {
|
|
|
8176
8432
|
'bar': jmBarSeries,
|
|
8177
8433
|
'stackBar': jmStackBarSeries,
|
|
8178
8434
|
'pie': jmPieSeries,
|
|
8179
|
-
'stackLine': jmStackLineSeries
|
|
8435
|
+
'stackLine': jmStackLineSeries,
|
|
8436
|
+
'candlestick': jmCandlestickSeries
|
|
8180
8437
|
};
|
|
8181
8438
|
} //默认样式为类型对应的样式
|
|
8182
8439
|
|