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