jmchart 1.1.79 → 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 +700 -444
- package/dist/jmchart.cjs.js +699 -443
- package/dist/jmchart.esm.js +699 -444
- package/dist/jmchart.iife.js +701 -443
- package/dist/jmchart.system.js +699 -443
- 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 -312
- 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.iife.js
CHANGED
|
@@ -874,6 +874,23 @@
|
|
|
874
874
|
}
|
|
875
875
|
return r;
|
|
876
876
|
}
|
|
877
|
+
// window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
|
|
878
|
+
static requestAnimationFrame(callback) {
|
|
879
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
880
|
+
return setTimeout(callback, 20);
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
return requestAnimationFrame(callback);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
static cancelAnimationFrame(handler) {
|
|
887
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
888
|
+
return clearTimeout(handler);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
return cancelAnimationFrame(handler);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
877
894
|
}
|
|
878
895
|
|
|
879
896
|
/**
|
|
@@ -3966,7 +3983,7 @@
|
|
|
3966
3983
|
|
|
3967
3984
|
//获取当前控件的绝对位置
|
|
3968
3985
|
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3969
|
-
|
|
3986
|
+
this.testSize();
|
|
3970
3987
|
let location = this.location;
|
|
3971
3988
|
let x = location.left + bounds.left;
|
|
3972
3989
|
let y = location.top + bounds.top;
|
|
@@ -4339,6 +4356,7 @@
|
|
|
4339
4356
|
|
|
4340
4357
|
touchStart(evt) {
|
|
4341
4358
|
evt = evt || window.event;
|
|
4359
|
+
evt.eventName = 'touchstart';
|
|
4342
4360
|
this.container.raiseEvent('touchstart',evt);
|
|
4343
4361
|
let t = evt.target || evt.srcElement;
|
|
4344
4362
|
if(t == this.target) {
|
|
@@ -4349,6 +4367,7 @@
|
|
|
4349
4367
|
|
|
4350
4368
|
touchMove(evt) {
|
|
4351
4369
|
evt = evt || window.event;
|
|
4370
|
+
evt.eventName = 'touchmove';
|
|
4352
4371
|
this.container.raiseEvent('touchmove',evt);
|
|
4353
4372
|
let t = evt.target || evt.srcElement;
|
|
4354
4373
|
if(t == this.target) {
|
|
@@ -4359,6 +4378,7 @@
|
|
|
4359
4378
|
|
|
4360
4379
|
touchEnd(evt) {
|
|
4361
4380
|
evt = evt || window.event;
|
|
4381
|
+
evt.eventName = 'touchend';
|
|
4362
4382
|
|
|
4363
4383
|
this.container.raiseEvent('touchend',evt);
|
|
4364
4384
|
let t = evt.target || evt.srcElement;
|
|
@@ -4370,6 +4390,7 @@
|
|
|
4370
4390
|
|
|
4371
4391
|
touchCancel(evt) {
|
|
4372
4392
|
evt = evt || window.event;
|
|
4393
|
+
evt.eventName = 'touchcancel';
|
|
4373
4394
|
|
|
4374
4395
|
this.container.raiseEvent('touchcancel',evt);
|
|
4375
4396
|
let t = evt.target || evt.srcElement;
|
|
@@ -4410,7 +4431,8 @@
|
|
|
4410
4431
|
|
|
4411
4432
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousedown',function(evt) {
|
|
4412
4433
|
evt = evt || window.event;
|
|
4413
|
-
|
|
4434
|
+
evt.eventName = 'mousedown';
|
|
4435
|
+
container.raiseEvent('mousedown',evt);
|
|
4414
4436
|
//if(r === false) {
|
|
4415
4437
|
//if(evt.preventDefault) evt.preventDefault();
|
|
4416
4438
|
//return false;
|
|
@@ -4419,9 +4441,10 @@
|
|
|
4419
4441
|
|
|
4420
4442
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousemove',function(evt) {
|
|
4421
4443
|
evt = evt || window.event;
|
|
4444
|
+
evt.eventName = 'mousemove';
|
|
4422
4445
|
let target = evt.target || evt.srcElement;
|
|
4423
4446
|
if(target == canvas) {
|
|
4424
|
-
|
|
4447
|
+
container.raiseEvent('mousemove',evt);
|
|
4425
4448
|
//if(r === false) {
|
|
4426
4449
|
if(evt.preventDefault) evt.preventDefault();
|
|
4427
4450
|
return false;
|
|
@@ -4430,19 +4453,23 @@
|
|
|
4430
4453
|
});
|
|
4431
4454
|
|
|
4432
4455
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mouseover',function(evt) {
|
|
4433
|
-
evt = evt || window.event;
|
|
4456
|
+
evt = evt || window.event;
|
|
4457
|
+
evt.eventName = 'mouseover';
|
|
4434
4458
|
container.raiseEvent('mouseover',evt);
|
|
4435
4459
|
});
|
|
4436
4460
|
this.eventEvents['mouseleave'] = jmUtils.bindEvent(this.target,'mouseleave',function(evt) {
|
|
4437
|
-
evt = evt || window.event;
|
|
4461
|
+
evt = evt || window.event;
|
|
4462
|
+
evt.eventName = 'mouseleave';
|
|
4438
4463
|
container.raiseEvent('mouseleave',evt);
|
|
4439
4464
|
});
|
|
4440
4465
|
this.eventEvents['mouseout'] = jmUtils.bindEvent(this.target,'mouseout',function(evt) {
|
|
4441
|
-
evt = evt || window.event;
|
|
4466
|
+
evt = evt || window.event;
|
|
4467
|
+
evt.eventName = 'mouseout';
|
|
4442
4468
|
container.raiseEvent('mouseout',evt);
|
|
4443
4469
|
});
|
|
4444
4470
|
doc && (this.eventEvents['mouseup'] = jmUtils.bindEvent(doc,'mouseup',function(evt) {
|
|
4445
|
-
evt = evt || window.event;
|
|
4471
|
+
evt = evt || window.event;
|
|
4472
|
+
evt.eventName = 'mouseup';
|
|
4446
4473
|
//let target = evt.target || evt.srcElement;
|
|
4447
4474
|
//if(target == canvas) {
|
|
4448
4475
|
let r = container.raiseEvent('mouseup',evt);
|
|
@@ -4455,33 +4482,40 @@
|
|
|
4455
4482
|
|
|
4456
4483
|
this.eventEvents['dblclick'] = jmUtils.bindEvent(this.target,'dblclick',function(evt) {
|
|
4457
4484
|
evt = evt || window.event;
|
|
4485
|
+
evt.eventName = 'dblclick';
|
|
4458
4486
|
container.raiseEvent('dblclick',evt);
|
|
4459
4487
|
});
|
|
4460
4488
|
this.eventEvents['click'] = jmUtils.bindEvent(this.target,'click',function(evt) {
|
|
4461
4489
|
evt = evt || window.event;
|
|
4490
|
+
evt.eventName = 'click';
|
|
4462
4491
|
container.raiseEvent('click',evt);
|
|
4463
4492
|
});
|
|
4464
4493
|
|
|
4465
4494
|
doc && (this.eventEvents['resize'] = jmUtils.bindEvent(doc,'resize',function(evt) {
|
|
4466
4495
|
evt = evt || window.event;
|
|
4496
|
+
evt.eventName = 'resize';
|
|
4467
4497
|
return container.raiseEvent('resize',evt);
|
|
4468
4498
|
}));
|
|
4469
4499
|
|
|
4470
4500
|
// passive: false 为了让浏览器不告警并且preventDefault有效
|
|
4471
4501
|
// 另一种处理:touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。
|
|
4472
4502
|
this.eventEvents['touchstart'] = jmUtils.bindEvent(this.target,'touchstart', function(evt) {
|
|
4503
|
+
evt.eventName = 'touchstart';
|
|
4473
4504
|
return instance.touchStart(evt);
|
|
4474
4505
|
},{ passive: false });
|
|
4475
4506
|
|
|
4476
4507
|
this.eventEvents['touchmove'] = jmUtils.bindEvent(this.target,'touchmove', function(evt) {
|
|
4508
|
+
evt.eventName = 'touchmove';
|
|
4477
4509
|
return instance.touchMove(evt);
|
|
4478
4510
|
},{ passive: false });
|
|
4479
4511
|
|
|
4480
4512
|
doc && (this.eventEvents['touchend'] = jmUtils.bindEvent(doc,'touchend', function(evt) {
|
|
4513
|
+
evt.eventName = 'touchend';
|
|
4481
4514
|
return instance.touchEnd(evt);
|
|
4482
4515
|
},{ passive: false }));
|
|
4483
4516
|
|
|
4484
4517
|
doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'touchcancel', function(evt) {
|
|
4518
|
+
evt.eventName = 'touchcancel';
|
|
4485
4519
|
return instance.touchCancel(evt);
|
|
4486
4520
|
},{ passive: false }));
|
|
4487
4521
|
}
|
|
@@ -4536,7 +4570,7 @@
|
|
|
4536
4570
|
return true;
|
|
4537
4571
|
};
|
|
4538
4572
|
|
|
4539
|
-
doc && (this.eventEvents['
|
|
4573
|
+
doc && (this.eventEvents['keypress'] = jmUtils.bindEvent(doc,'keypress',function(evt) {
|
|
4540
4574
|
evt = evt || window.event;
|
|
4541
4575
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4542
4576
|
let r = container.raiseEvent('keypress',evt);
|
|
@@ -4544,7 +4578,7 @@
|
|
|
4544
4578
|
evt.preventDefault();
|
|
4545
4579
|
return r;
|
|
4546
4580
|
}));
|
|
4547
|
-
doc && (this.eventEvents['
|
|
4581
|
+
doc && (this.eventEvents['keydown'] = jmUtils.bindEvent(doc,'keydown',function(evt) {
|
|
4548
4582
|
evt = evt || window.event;
|
|
4549
4583
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4550
4584
|
let r = container.raiseEvent('keydown',evt);
|
|
@@ -4552,7 +4586,7 @@
|
|
|
4552
4586
|
evt.preventDefault();
|
|
4553
4587
|
return r;
|
|
4554
4588
|
}));
|
|
4555
|
-
doc && (this.eventEvents['
|
|
4589
|
+
doc && (this.eventEvents['keyup'] = jmUtils.bindEvent(doc,'keyup',function(evt) {
|
|
4556
4590
|
evt = evt || window.event;
|
|
4557
4591
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
4558
4592
|
let r = container.raiseEvent('keyup',evt);
|
|
@@ -4583,7 +4617,7 @@
|
|
|
4583
4617
|
* @param {object} option 参数:{width:宽,height:高}
|
|
4584
4618
|
* @param {function} callback 初始化后的回调
|
|
4585
4619
|
*/
|
|
4586
|
-
class jmGraph extends jmControl {
|
|
4620
|
+
class jmGraph$1 extends jmControl {
|
|
4587
4621
|
|
|
4588
4622
|
constructor(canvas, option, callback) {
|
|
4589
4623
|
if(typeof option == 'function') {
|
|
@@ -4761,7 +4795,7 @@
|
|
|
4761
4795
|
* @return {jmGraph} jmGraph实例对象
|
|
4762
4796
|
*/
|
|
4763
4797
|
static create(...args) {
|
|
4764
|
-
return new jmGraph(...args);
|
|
4798
|
+
return new jmGraph$1(...args);
|
|
4765
4799
|
}
|
|
4766
4800
|
|
|
4767
4801
|
/**
|
|
@@ -5061,26 +5095,19 @@
|
|
|
5061
5095
|
if(this.___isAutoRefreshing) return;
|
|
5062
5096
|
const self = this;
|
|
5063
5097
|
this.___isAutoRefreshing = true;
|
|
5064
|
-
|
|
5065
|
-
if(typeof requestAnimationFrame === 'undefined') {
|
|
5066
|
-
requestAnimationFrameFun = (fun) => {
|
|
5067
|
-
if(this.__requestAnimationFrameFunHandler) clearTimeout(this.__requestAnimationFrameFunHandler);
|
|
5068
|
-
this.__requestAnimationFrameFunHandler = setTimeout(fun, 20);
|
|
5069
|
-
};
|
|
5070
|
-
}
|
|
5071
|
-
else {
|
|
5072
|
-
requestAnimationFrameFun = requestAnimationFrame;
|
|
5073
|
-
}
|
|
5098
|
+
|
|
5074
5099
|
function update() {
|
|
5075
5100
|
if(self.destoryed) {
|
|
5076
5101
|
self.___isAutoRefreshing = false;
|
|
5077
5102
|
return;// 已销毁
|
|
5078
5103
|
}
|
|
5079
5104
|
if(self.needUpdate) self.redraw();
|
|
5080
|
-
|
|
5105
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5106
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5081
5107
|
if(callback) callback();
|
|
5082
5108
|
}
|
|
5083
|
-
|
|
5109
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5110
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5084
5111
|
return this;
|
|
5085
5112
|
}
|
|
5086
5113
|
|
|
@@ -5107,7 +5134,7 @@
|
|
|
5107
5134
|
"resize": jmResize
|
|
5108
5135
|
};
|
|
5109
5136
|
|
|
5110
|
-
class jmGraph
|
|
5137
|
+
class jmGraph extends jmGraph$1 {
|
|
5111
5138
|
constructor(canvas, option, callback) {
|
|
5112
5139
|
|
|
5113
5140
|
const targetType = new.target;
|
|
@@ -5117,9 +5144,9 @@
|
|
|
5117
5144
|
option.shapes = Object.assign(shapes, option.shapes||{});
|
|
5118
5145
|
|
|
5119
5146
|
//不是用new实例化的话,返回一个promise
|
|
5120
|
-
if(!targetType || !(targetType.prototype instanceof jmGraph)) {
|
|
5147
|
+
if(!targetType || !(targetType.prototype instanceof jmGraph$1)) {
|
|
5121
5148
|
return new Promise(function(resolve, reject){
|
|
5122
|
-
var g = new jmGraph
|
|
5149
|
+
var g = new jmGraph(canvas, option, callback);
|
|
5123
5150
|
if(resolve) resolve(g);
|
|
5124
5151
|
});
|
|
5125
5152
|
}
|
|
@@ -5133,12 +5160,12 @@
|
|
|
5133
5160
|
}
|
|
5134
5161
|
}
|
|
5135
5162
|
|
|
5136
|
-
/**
|
|
5137
|
-
* 基础样式
|
|
5138
|
-
*
|
|
5139
|
-
* @class jmChartStyle
|
|
5140
|
-
* @module jmChart
|
|
5141
|
-
* @static
|
|
5163
|
+
/**
|
|
5164
|
+
* 基础样式
|
|
5165
|
+
*
|
|
5166
|
+
* @class jmChartStyle
|
|
5167
|
+
* @module jmChart
|
|
5168
|
+
* @static
|
|
5142
5169
|
*/
|
|
5143
5170
|
var defaultStyle = {
|
|
5144
5171
|
layout: 'normal',
|
|
@@ -5274,13 +5301,13 @@
|
|
|
5274
5301
|
// 图形样式集
|
|
5275
5302
|
chartColors: ['#249FDA', '#EA3B7C', '#8EBC00', '#309B46', '#4B507E', '#D8E404', '#EB792A', '#A00DA0'],
|
|
5276
5303
|
|
|
5277
|
-
/*tooltip: {
|
|
5278
|
-
'background-color': 'rgb(255,255,255)',
|
|
5279
|
-
'padding':'4px',
|
|
5280
|
-
'opacity':'0.8',
|
|
5281
|
-
'border':'1px solid #000',
|
|
5282
|
-
'box-shadow': '0 0 3px #000',
|
|
5283
|
-
'border-radius': '6px'
|
|
5304
|
+
/*tooltip: {
|
|
5305
|
+
'background-color': 'rgb(255,255,255)',
|
|
5306
|
+
'padding':'4px',
|
|
5307
|
+
'opacity':'0.8',
|
|
5308
|
+
'border':'1px solid #000',
|
|
5309
|
+
'box-shadow': '0 0 3px #000',
|
|
5310
|
+
'border-radius': '6px'
|
|
5284
5311
|
},*/
|
|
5285
5312
|
line: {
|
|
5286
5313
|
normal: {
|
|
@@ -5387,18 +5414,35 @@
|
|
|
5387
5414
|
blur: 2,
|
|
5388
5415
|
color: '#ccc'
|
|
5389
5416
|
}
|
|
5417
|
+
},
|
|
5418
|
+
candlestick: {
|
|
5419
|
+
normal: {
|
|
5420
|
+
lineWidth: 1,
|
|
5421
|
+
zIndex: 18,
|
|
5422
|
+
cursor: 'default'
|
|
5423
|
+
},
|
|
5424
|
+
hover: {
|
|
5425
|
+
//zIndex: 100,
|
|
5426
|
+
cursor: 'pointer'
|
|
5427
|
+
},
|
|
5428
|
+
perWidth: 0.5,
|
|
5429
|
+
// 阴线颜色
|
|
5430
|
+
negativeColor: 'green',
|
|
5431
|
+
// 阳线颜色
|
|
5432
|
+
masculineColor: 'red',
|
|
5433
|
+
lineWidth: 1
|
|
5390
5434
|
}
|
|
5391
5435
|
};
|
|
5392
5436
|
|
|
5393
|
-
/**
|
|
5394
|
-
* 轴
|
|
5395
|
-
*
|
|
5396
|
-
* @class jmAxis
|
|
5397
|
-
* @module jmChart
|
|
5398
|
-
* @param {jmChart} chart 当前图表
|
|
5399
|
-
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
5400
|
-
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
5401
|
-
* @param {object} [style] 样式
|
|
5437
|
+
/**
|
|
5438
|
+
* 轴
|
|
5439
|
+
*
|
|
5440
|
+
* @class jmAxis
|
|
5441
|
+
* @module jmChart
|
|
5442
|
+
* @param {jmChart} chart 当前图表
|
|
5443
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
5444
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
5445
|
+
* @param {object} [style] 样式
|
|
5402
5446
|
*/
|
|
5403
5447
|
|
|
5404
5448
|
class jmAxis extends jmArrowLine {
|
|
@@ -5445,21 +5489,21 @@
|
|
|
5445
5489
|
|
|
5446
5490
|
if (typeof options.minXValue !== 'undefined') this.minValue = options.minXValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5447
5491
|
} else {
|
|
5448
|
-
if (typeof options.maxYValue !== 'undefined') this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
5492
|
+
if (typeof options.maxYValue !== 'undefined' && (options.maxYValue > this.maxValue || typeof this.maxValue === 'undefined')) this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
5449
5493
|
|
|
5450
|
-
if (typeof options.minYValue !== 'undefined') this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5494
|
+
if (typeof options.minYValue !== 'undefined' && (options.minYValue < this.minValue || typeof this.minValue === 'undefined')) this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
|
|
5451
5495
|
}
|
|
5452
5496
|
}
|
|
5453
|
-
/**
|
|
5454
|
-
* 轴类型(x/y/radar),默认为x
|
|
5455
|
-
*
|
|
5456
|
-
* @property type
|
|
5457
|
-
* @type string
|
|
5497
|
+
/**
|
|
5498
|
+
* 轴类型(x/y/radar),默认为x
|
|
5499
|
+
*
|
|
5500
|
+
* @property type
|
|
5501
|
+
* @type string
|
|
5458
5502
|
*/
|
|
5459
5503
|
|
|
5460
5504
|
|
|
5461
|
-
/**
|
|
5462
|
-
* 关联访问的是chart的数据源
|
|
5505
|
+
/**
|
|
5506
|
+
* 关联访问的是chart的数据源
|
|
5463
5507
|
*/
|
|
5464
5508
|
get data() {
|
|
5465
5509
|
return this.graph.data;
|
|
@@ -5468,10 +5512,10 @@
|
|
|
5468
5512
|
set data(d) {
|
|
5469
5513
|
this.graph.data = d;
|
|
5470
5514
|
}
|
|
5471
|
-
/**
|
|
5472
|
-
* 计算当前轴的位置
|
|
5473
|
-
*
|
|
5474
|
-
* @method reset
|
|
5515
|
+
/**
|
|
5516
|
+
* 计算当前轴的位置
|
|
5517
|
+
*
|
|
5518
|
+
* @method reset
|
|
5475
5519
|
*/
|
|
5476
5520
|
|
|
5477
5521
|
|
|
@@ -5529,10 +5573,10 @@
|
|
|
5529
5573
|
|
|
5530
5574
|
super.draw();
|
|
5531
5575
|
}
|
|
5532
|
-
/**
|
|
5533
|
-
* 生成轴标签
|
|
5534
|
-
*
|
|
5535
|
-
* @method createLabel
|
|
5576
|
+
/**
|
|
5577
|
+
* 生成轴标签
|
|
5578
|
+
*
|
|
5579
|
+
* @method createLabel
|
|
5536
5580
|
*/
|
|
5537
5581
|
|
|
5538
5582
|
|
|
@@ -5549,11 +5593,11 @@
|
|
|
5549
5593
|
this.createYLabel();
|
|
5550
5594
|
}
|
|
5551
5595
|
}
|
|
5552
|
-
/**
|
|
5553
|
-
* 生成X轴标签
|
|
5554
|
-
*
|
|
5555
|
-
* @method createXLabel
|
|
5556
|
-
* @private
|
|
5596
|
+
/**
|
|
5597
|
+
* 生成X轴标签
|
|
5598
|
+
*
|
|
5599
|
+
* @method createXLabel
|
|
5600
|
+
* @private
|
|
5557
5601
|
*/
|
|
5558
5602
|
|
|
5559
5603
|
|
|
@@ -5577,7 +5621,7 @@
|
|
|
5577
5621
|
|
|
5578
5622
|
if (!text) continue; /// 只有一条数据,就取这条数据就可以了
|
|
5579
5623
|
|
|
5580
|
-
const w =
|
|
5624
|
+
const w = i * step;
|
|
5581
5625
|
const label = this.graph.createShape('label', {
|
|
5582
5626
|
style: this.style.xLabel
|
|
5583
5627
|
});
|
|
@@ -5644,11 +5688,11 @@
|
|
|
5644
5688
|
}
|
|
5645
5689
|
}
|
|
5646
5690
|
}
|
|
5647
|
-
/**
|
|
5648
|
-
* 生成Y轴标签
|
|
5649
|
-
*
|
|
5650
|
-
* @method createYLabel
|
|
5651
|
-
* @private
|
|
5691
|
+
/**
|
|
5692
|
+
* 生成Y轴标签
|
|
5693
|
+
*
|
|
5694
|
+
* @method createYLabel
|
|
5695
|
+
* @private
|
|
5652
5696
|
*/
|
|
5653
5697
|
|
|
5654
5698
|
|
|
@@ -5661,8 +5705,8 @@
|
|
|
5661
5705
|
|
|
5662
5706
|
let count = this.labelCount;
|
|
5663
5707
|
const mm = max - min;
|
|
5664
|
-
/*if(mm <= 10) {
|
|
5665
|
-
count = mm;
|
|
5708
|
+
/*if(mm <= 10) {
|
|
5709
|
+
count = mm;
|
|
5666
5710
|
}*/
|
|
5667
5711
|
// mm 放大10000倍,这里结果也需要除于10000
|
|
5668
5712
|
|
|
@@ -5774,10 +5818,10 @@
|
|
|
5774
5818
|
}
|
|
5775
5819
|
}
|
|
5776
5820
|
}
|
|
5777
|
-
/**
|
|
5778
|
-
* 获取当前轴所占宽
|
|
5779
|
-
*
|
|
5780
|
-
* @method width
|
|
5821
|
+
/**
|
|
5822
|
+
* 获取当前轴所占宽
|
|
5823
|
+
*
|
|
5824
|
+
* @method width
|
|
5781
5825
|
*/
|
|
5782
5826
|
|
|
5783
5827
|
|
|
@@ -5792,10 +5836,10 @@
|
|
|
5792
5836
|
set width(w) {
|
|
5793
5837
|
this._width = w;
|
|
5794
5838
|
}
|
|
5795
|
-
/**
|
|
5796
|
-
* 获取当前轴所占高
|
|
5797
|
-
*
|
|
5798
|
-
* @method height
|
|
5839
|
+
/**
|
|
5840
|
+
* 获取当前轴所占高
|
|
5841
|
+
*
|
|
5842
|
+
* @method height
|
|
5799
5843
|
*/
|
|
5800
5844
|
|
|
5801
5845
|
|
|
@@ -5805,12 +5849,12 @@
|
|
|
5805
5849
|
|
|
5806
5850
|
|
|
5807
5851
|
set height(h) {}
|
|
5808
|
-
/**
|
|
5809
|
-
* 获取或设置当前轴最大值
|
|
5810
|
-
*
|
|
5811
|
-
* @method max
|
|
5812
|
-
* @param {number/date/string} 当前轴的最大值
|
|
5813
|
-
* @return 当前轴的最大值
|
|
5852
|
+
/**
|
|
5853
|
+
* 获取或设置当前轴最大值
|
|
5854
|
+
*
|
|
5855
|
+
* @method max
|
|
5856
|
+
* @param {number/date/string} 当前轴的最大值
|
|
5857
|
+
* @return 当前轴的最大值
|
|
5814
5858
|
*/
|
|
5815
5859
|
|
|
5816
5860
|
|
|
@@ -5859,12 +5903,12 @@
|
|
|
5859
5903
|
|
|
5860
5904
|
return this._max;
|
|
5861
5905
|
}
|
|
5862
|
-
/**
|
|
5863
|
-
* 获取或设置当前轴最小值
|
|
5864
|
-
*
|
|
5865
|
-
* @method max
|
|
5866
|
-
* @param {number/date/string} 当前轴的最小值
|
|
5867
|
-
* @return 当前轴的最小值
|
|
5906
|
+
/**
|
|
5907
|
+
* 获取或设置当前轴最小值
|
|
5908
|
+
*
|
|
5909
|
+
* @method max
|
|
5910
|
+
* @param {number/date/string} 当前轴的最小值
|
|
5911
|
+
* @return 当前轴的最小值
|
|
5868
5912
|
*/
|
|
5869
5913
|
|
|
5870
5914
|
|
|
@@ -5911,10 +5955,10 @@
|
|
|
5911
5955
|
|
|
5912
5956
|
return this.dataType == 'string' ? 0 : this._min;
|
|
5913
5957
|
}
|
|
5914
|
-
/**
|
|
5915
|
-
* 清除一些属性
|
|
5916
|
-
*
|
|
5917
|
-
* @method clear
|
|
5958
|
+
/**
|
|
5959
|
+
* 清除一些属性
|
|
5960
|
+
*
|
|
5961
|
+
* @method clear
|
|
5918
5962
|
*/
|
|
5919
5963
|
|
|
5920
5964
|
|
|
@@ -5922,11 +5966,11 @@
|
|
|
5922
5966
|
this._min = null;
|
|
5923
5967
|
this._max = null;
|
|
5924
5968
|
}
|
|
5925
|
-
/**
|
|
5926
|
-
* 计算当前轴的单位偏移量
|
|
5927
|
-
*
|
|
5928
|
-
* @method step
|
|
5929
|
-
* @return {number} 单位偏移量
|
|
5969
|
+
/**
|
|
5970
|
+
* 计算当前轴的单位偏移量
|
|
5971
|
+
*
|
|
5972
|
+
* @method step
|
|
5973
|
+
* @return {number} 单位偏移量
|
|
5930
5974
|
*/
|
|
5931
5975
|
|
|
5932
5976
|
|
|
@@ -5975,12 +6019,12 @@
|
|
|
5975
6019
|
|
|
5976
6020
|
}
|
|
5977
6021
|
|
|
5978
|
-
/**
|
|
5979
|
-
* 图例的容器
|
|
5980
|
-
*
|
|
5981
|
-
* @class jmLegend
|
|
5982
|
-
* @module jmChart
|
|
5983
|
-
* @param {jmChart} chart 当前图表
|
|
6022
|
+
/**
|
|
6023
|
+
* 图例的容器
|
|
6024
|
+
*
|
|
6025
|
+
* @class jmLegend
|
|
6026
|
+
* @module jmChart
|
|
6027
|
+
* @param {jmChart} chart 当前图表
|
|
5984
6028
|
*/
|
|
5985
6029
|
|
|
5986
6030
|
class jmLegend extends jmRect {
|
|
@@ -5992,20 +6036,20 @@
|
|
|
5992
6036
|
};
|
|
5993
6037
|
super(options);
|
|
5994
6038
|
|
|
5995
|
-
_defineProperty(this, "legendPosition", '
|
|
6039
|
+
_defineProperty(this, "legendPosition", '');
|
|
5996
6040
|
}
|
|
5997
|
-
/**
|
|
5998
|
-
* 图例放置位置
|
|
6041
|
+
/**
|
|
6042
|
+
* 图例放置位置
|
|
5999
6043
|
*/
|
|
6000
6044
|
|
|
6001
6045
|
|
|
6002
6046
|
}
|
|
6003
|
-
/**
|
|
6004
|
-
* 添加图例
|
|
6005
|
-
*
|
|
6006
|
-
* @method append
|
|
6007
|
-
* @param {jmSeries} series 当前图序列
|
|
6008
|
-
* @param {jmControl} shape 当前图例的图形对象
|
|
6047
|
+
/**
|
|
6048
|
+
* 添加图例
|
|
6049
|
+
*
|
|
6050
|
+
* @method append
|
|
6051
|
+
* @param {jmSeries} series 当前图序列
|
|
6052
|
+
* @param {jmControl} shape 当前图例的图形对象
|
|
6009
6053
|
*/
|
|
6010
6054
|
|
|
6011
6055
|
jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
@@ -6045,24 +6089,27 @@
|
|
|
6045
6089
|
panel.height = shape.height; //执行进入事件
|
|
6046
6090
|
//触动图例后加粗显示图
|
|
6047
6091
|
|
|
6048
|
-
/*const hover = options.hover || function() {
|
|
6049
|
-
//应用图的动态样式
|
|
6050
|
-
//Object.assign(series.style, series.style.hover);
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
//
|
|
6061
|
-
|
|
6062
|
-
|
|
6092
|
+
/*const hover = options.hover || function() {
|
|
6093
|
+
//应用图的动态样式
|
|
6094
|
+
//Object.assign(series.style, series.style.hover);
|
|
6095
|
+
|
|
6096
|
+
//Object.assign(this.style, this.style.hover || {});
|
|
6097
|
+
|
|
6098
|
+
//series.graph.refresh();
|
|
6099
|
+
};
|
|
6100
|
+
panel.bind('mouseover', hover);
|
|
6101
|
+
//执行离开
|
|
6102
|
+
const leave = options.leave || function() {
|
|
6103
|
+
//应用图的普通样式
|
|
6104
|
+
//Object.assign(series.style, series.style.normal);
|
|
6105
|
+
|
|
6106
|
+
//Object.assign(this.style, this.style.normal || {});
|
|
6107
|
+
//jmUtils.apply(this.series.style.normal,this.series.style);
|
|
6108
|
+
//series.graph.refresh();
|
|
6109
|
+
};
|
|
6063
6110
|
panel.bind('mouseleave', leave);*/
|
|
6064
6111
|
|
|
6065
|
-
const legendPosition = this.legendPosition || this.style.legendPosition;
|
|
6112
|
+
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
6066
6113
|
|
|
6067
6114
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6068
6115
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
@@ -6079,10 +6126,10 @@
|
|
|
6079
6126
|
|
|
6080
6127
|
this.needUpdate = true;
|
|
6081
6128
|
};
|
|
6082
|
-
/**
|
|
6083
|
-
* 初始化图例
|
|
6084
|
-
*
|
|
6085
|
-
* @method init
|
|
6129
|
+
/**
|
|
6130
|
+
* 初始化图例
|
|
6131
|
+
*
|
|
6132
|
+
* @method init
|
|
6086
6133
|
*/
|
|
6087
6134
|
|
|
6088
6135
|
|
|
@@ -6094,10 +6141,10 @@
|
|
|
6094
6141
|
this.style.lineWidth = 0;
|
|
6095
6142
|
this.children.clear();
|
|
6096
6143
|
};
|
|
6097
|
-
/**
|
|
6098
|
-
* 重置图例属性,根据图例内容计算期大小并更新画图区域大小
|
|
6099
|
-
*
|
|
6100
|
-
* @method reset
|
|
6144
|
+
/**
|
|
6145
|
+
* 重置图例属性,根据图例内容计算期大小并更新画图区域大小
|
|
6146
|
+
*
|
|
6147
|
+
* @method reset
|
|
6101
6148
|
*/
|
|
6102
6149
|
|
|
6103
6150
|
|
|
@@ -6142,11 +6189,11 @@
|
|
|
6142
6189
|
};
|
|
6143
6190
|
|
|
6144
6191
|
var utils = {
|
|
6145
|
-
/**
|
|
6146
|
-
* 对比二个数组数据是否改变
|
|
6147
|
-
* @param {Array} source 被对比的数、组
|
|
6148
|
-
* @param {Array} target 对比数组
|
|
6149
|
-
* @param {Function} compare 比较函数
|
|
6192
|
+
/**
|
|
6193
|
+
* 对比二个数组数据是否改变
|
|
6194
|
+
* @param {Array} source 被对比的数、组
|
|
6195
|
+
* @param {Array} target 对比数组
|
|
6196
|
+
* @param {Function} compare 比较函数
|
|
6150
6197
|
*/
|
|
6151
6198
|
arrayIsChange(source, target, compare) {
|
|
6152
6199
|
if (!source || !target) return true;
|
|
@@ -6163,14 +6210,14 @@
|
|
|
6163
6210
|
|
|
6164
6211
|
};
|
|
6165
6212
|
|
|
6166
|
-
/**
|
|
6167
|
-
* 图形基类
|
|
6168
|
-
*
|
|
6169
|
-
* @class jmSeries
|
|
6170
|
-
* @module jmChart
|
|
6171
|
-
* @param {jmChart} chart 当前图表
|
|
6172
|
-
* @param {array} mappings 图形字段映射
|
|
6173
|
-
* @param {style} style 样式
|
|
6213
|
+
/**
|
|
6214
|
+
* 图形基类
|
|
6215
|
+
*
|
|
6216
|
+
* @class jmSeries
|
|
6217
|
+
* @module jmChart
|
|
6218
|
+
* @param {jmChart} chart 当前图表
|
|
6219
|
+
* @param {array} mappings 图形字段映射
|
|
6220
|
+
* @param {style} style 样式
|
|
6174
6221
|
*/
|
|
6175
6222
|
//构造线图
|
|
6176
6223
|
|
|
@@ -6214,8 +6261,8 @@
|
|
|
6214
6261
|
maxYValue: options.maxYValue
|
|
6215
6262
|
});
|
|
6216
6263
|
}
|
|
6217
|
-
/**
|
|
6218
|
-
* 关联访问的是chart的数据源
|
|
6264
|
+
/**
|
|
6265
|
+
* 关联访问的是chart的数据源
|
|
6219
6266
|
*/
|
|
6220
6267
|
|
|
6221
6268
|
|
|
@@ -6237,11 +6284,11 @@
|
|
|
6237
6284
|
set enableAnimate(v) {
|
|
6238
6285
|
this.option.enableAnimate = v;
|
|
6239
6286
|
}
|
|
6240
|
-
/**
|
|
6241
|
-
* 图例名称
|
|
6242
|
-
*
|
|
6243
|
-
* @property legendLabel
|
|
6244
|
-
* @type string
|
|
6287
|
+
/**
|
|
6288
|
+
* 图例名称
|
|
6289
|
+
*
|
|
6290
|
+
* @property legendLabel
|
|
6291
|
+
* @type string
|
|
6245
6292
|
*/
|
|
6246
6293
|
|
|
6247
6294
|
|
|
@@ -6271,10 +6318,10 @@
|
|
|
6271
6318
|
points: this.dataPoints
|
|
6272
6319
|
};
|
|
6273
6320
|
}
|
|
6274
|
-
/**
|
|
6275
|
-
* 根据X轴坐标,获取它最近的数据描点
|
|
6276
|
-
* 离点最近的一个描点
|
|
6277
|
-
* @param {number} x X轴坐标
|
|
6321
|
+
/**
|
|
6322
|
+
* 根据X轴坐标,获取它最近的数据描点
|
|
6323
|
+
* 离点最近的一个描点
|
|
6324
|
+
* @param {number} x X轴坐标
|
|
6278
6325
|
*/
|
|
6279
6326
|
|
|
6280
6327
|
|
|
@@ -6294,7 +6341,7 @@
|
|
|
6294
6341
|
} // 下一个点
|
|
6295
6342
|
|
|
6296
6343
|
|
|
6297
|
-
if (
|
|
6344
|
+
if (p.x > x) {
|
|
6298
6345
|
// 没有上一个,只能返回这个了
|
|
6299
6346
|
if (prePoint && x - prePoint.x < p.x - x) return prePoint;else return p;
|
|
6300
6347
|
}
|
|
@@ -6302,9 +6349,9 @@
|
|
|
6302
6349
|
|
|
6303
6350
|
return null;
|
|
6304
6351
|
}
|
|
6305
|
-
/**
|
|
6306
|
-
* 根据X轴值获取数据点
|
|
6307
|
-
* @param {number} xValue X轴值
|
|
6352
|
+
/**
|
|
6353
|
+
* 根据X轴值获取数据点
|
|
6354
|
+
* @param {number} xValue X轴值
|
|
6308
6355
|
*/
|
|
6309
6356
|
|
|
6310
6357
|
|
|
@@ -6318,11 +6365,11 @@
|
|
|
6318
6365
|
|
|
6319
6366
|
return null;
|
|
6320
6367
|
}
|
|
6321
|
-
/**
|
|
6322
|
-
* 重置属性
|
|
6323
|
-
* 根据数据源计算轴的属性
|
|
6324
|
-
*
|
|
6325
|
-
* @method reset
|
|
6368
|
+
/**
|
|
6369
|
+
* 重置属性
|
|
6370
|
+
* 根据数据源计算轴的属性
|
|
6371
|
+
*
|
|
6372
|
+
* @method reset
|
|
6326
6373
|
*/
|
|
6327
6374
|
|
|
6328
6375
|
|
|
@@ -6366,10 +6413,10 @@
|
|
|
6366
6413
|
this.xAxis.min(xv);
|
|
6367
6414
|
}
|
|
6368
6415
|
}
|
|
6369
|
-
/**
|
|
6370
|
-
* 生成序列图描点
|
|
6371
|
-
*
|
|
6372
|
-
* @method createPoints
|
|
6416
|
+
/**
|
|
6417
|
+
* 生成序列图描点
|
|
6418
|
+
*
|
|
6419
|
+
* @method createPoints
|
|
6373
6420
|
*/
|
|
6374
6421
|
|
|
6375
6422
|
|
|
@@ -6400,7 +6447,7 @@
|
|
|
6400
6447
|
style: this.graph.utils.clone(this.style)
|
|
6401
6448
|
}; // 这里的点应相对于chartArea
|
|
6402
6449
|
|
|
6403
|
-
p.x = xstep *
|
|
6450
|
+
p.x = xstep * i + this.xAxis.labelStart;
|
|
6404
6451
|
|
|
6405
6452
|
for (const f of fields) {
|
|
6406
6453
|
const yv = s[f];
|
|
@@ -6411,7 +6458,8 @@
|
|
|
6411
6458
|
x: p.x,
|
|
6412
6459
|
// 高度
|
|
6413
6460
|
height: p.height,
|
|
6414
|
-
yValue: yv
|
|
6461
|
+
yValue: yv,
|
|
6462
|
+
field: f
|
|
6415
6463
|
}; //如果Y值不存在。则此点无效,不画图
|
|
6416
6464
|
|
|
6417
6465
|
if (yv == null || typeof yv == 'undefined') {
|
|
@@ -6446,10 +6494,10 @@
|
|
|
6446
6494
|
return this.style.color;
|
|
6447
6495
|
}
|
|
6448
6496
|
}
|
|
6449
|
-
/**
|
|
6450
|
-
* 生成图例
|
|
6451
|
-
*
|
|
6452
|
-
* @method createLegend
|
|
6497
|
+
/**
|
|
6498
|
+
* 生成图例
|
|
6499
|
+
*
|
|
6500
|
+
* @method createLegend
|
|
6453
6501
|
*/
|
|
6454
6502
|
|
|
6455
6503
|
|
|
@@ -6501,9 +6549,9 @@
|
|
|
6501
6549
|
});
|
|
6502
6550
|
this.addShape(label);
|
|
6503
6551
|
}
|
|
6504
|
-
/**
|
|
6505
|
-
* 在图上加下定制图形
|
|
6506
|
-
* @param {jmShape} shape 图形
|
|
6552
|
+
/**
|
|
6553
|
+
* 在图上加下定制图形
|
|
6554
|
+
* @param {jmShape} shape 图形
|
|
6507
6555
|
*/
|
|
6508
6556
|
|
|
6509
6557
|
|
|
@@ -6512,13 +6560,13 @@
|
|
|
6512
6560
|
this.shapes.add(shape);
|
|
6513
6561
|
return shape;
|
|
6514
6562
|
}
|
|
6515
|
-
/**
|
|
6516
|
-
* 获取指定事件的集合
|
|
6517
|
-
* 比如mousedown,mouseup等
|
|
6518
|
-
*
|
|
6519
|
-
* @method getEvent
|
|
6520
|
-
* @param {string} name 事件名称
|
|
6521
|
-
* @return {list} 事件委托的集合
|
|
6563
|
+
/**
|
|
6564
|
+
* 获取指定事件的集合
|
|
6565
|
+
* 比如mousedown,mouseup等
|
|
6566
|
+
*
|
|
6567
|
+
* @method getEvent
|
|
6568
|
+
* @param {string} name 事件名称
|
|
6569
|
+
* @return {list} 事件委托的集合
|
|
6522
6570
|
*/
|
|
6523
6571
|
|
|
6524
6572
|
|
|
@@ -6542,14 +6590,14 @@
|
|
|
6542
6590
|
|
|
6543
6591
|
}
|
|
6544
6592
|
|
|
6545
|
-
/**
|
|
6546
|
-
* 柱图
|
|
6547
|
-
*
|
|
6548
|
-
* @class jmBarSeries
|
|
6549
|
-
* @module jmChart
|
|
6550
|
-
* @param {jmChart} chart 当前图表
|
|
6551
|
-
* @param {array} mappings 图形字段映射
|
|
6552
|
-
* @param {style} style 样式
|
|
6593
|
+
/**
|
|
6594
|
+
* 柱图
|
|
6595
|
+
*
|
|
6596
|
+
* @class jmBarSeries
|
|
6597
|
+
* @module jmChart
|
|
6598
|
+
* @param {jmChart} chart 当前图表
|
|
6599
|
+
* @param {array} mappings 图形字段映射
|
|
6600
|
+
* @param {style} style 样式
|
|
6553
6601
|
*/
|
|
6554
6602
|
//构造函数
|
|
6555
6603
|
|
|
@@ -6557,11 +6605,11 @@
|
|
|
6557
6605
|
constructor(options) {
|
|
6558
6606
|
super(options);
|
|
6559
6607
|
}
|
|
6560
|
-
/**
|
|
6561
|
-
* 绘制当前图形
|
|
6562
|
-
*
|
|
6563
|
-
* @method beginDraw
|
|
6564
|
-
* @for jmBarSeries
|
|
6608
|
+
/**
|
|
6609
|
+
* 绘制当前图形
|
|
6610
|
+
*
|
|
6611
|
+
* @method beginDraw
|
|
6612
|
+
* @for jmBarSeries
|
|
6565
6613
|
*/
|
|
6566
6614
|
|
|
6567
6615
|
|
|
@@ -6668,9 +6716,9 @@
|
|
|
6668
6716
|
this.barTotalWidth = maxWidth * this.graph.barSeriesCount;
|
|
6669
6717
|
}
|
|
6670
6718
|
}
|
|
6671
|
-
/**
|
|
6672
|
-
* 在图上加下定制图形
|
|
6673
|
-
* @param {jmShape} shape 图形
|
|
6719
|
+
/**
|
|
6720
|
+
* 在图上加下定制图形
|
|
6721
|
+
* @param {jmShape} shape 图形
|
|
6674
6722
|
*/
|
|
6675
6723
|
|
|
6676
6724
|
|
|
@@ -6682,14 +6730,14 @@
|
|
|
6682
6730
|
|
|
6683
6731
|
}
|
|
6684
6732
|
|
|
6685
|
-
/**
|
|
6686
|
-
* 柱图
|
|
6687
|
-
*
|
|
6688
|
-
* @class jmBarSeries
|
|
6689
|
-
* @module jmChart
|
|
6690
|
-
* @param {jmChart} chart 当前图表
|
|
6691
|
-
* @param {array} mappings 图形字段映射
|
|
6692
|
-
* @param {style} style 样式
|
|
6733
|
+
/**
|
|
6734
|
+
* 柱图
|
|
6735
|
+
*
|
|
6736
|
+
* @class jmBarSeries
|
|
6737
|
+
* @module jmChart
|
|
6738
|
+
* @param {jmChart} chart 当前图表
|
|
6739
|
+
* @param {array} mappings 图形字段映射
|
|
6740
|
+
* @param {style} style 样式
|
|
6693
6741
|
*/
|
|
6694
6742
|
//构造函数
|
|
6695
6743
|
|
|
@@ -6697,11 +6745,11 @@
|
|
|
6697
6745
|
constructor(options) {
|
|
6698
6746
|
super(options);
|
|
6699
6747
|
}
|
|
6700
|
-
/**
|
|
6701
|
-
* 绘制当前图形
|
|
6702
|
-
*
|
|
6703
|
-
* @method beginDraw
|
|
6704
|
-
* @for jmBarSeries
|
|
6748
|
+
/**
|
|
6749
|
+
* 绘制当前图形
|
|
6750
|
+
*
|
|
6751
|
+
* @method beginDraw
|
|
6752
|
+
* @for jmBarSeries
|
|
6705
6753
|
*/
|
|
6706
6754
|
|
|
6707
6755
|
|
|
@@ -6831,14 +6879,14 @@
|
|
|
6831
6879
|
|
|
6832
6880
|
}
|
|
6833
6881
|
|
|
6834
|
-
/**
|
|
6835
|
-
* 饼图
|
|
6836
|
-
*
|
|
6837
|
-
* @class jmPieSeries
|
|
6838
|
-
* @module jmChart
|
|
6839
|
-
* @param {jmChart} chart 当前图表
|
|
6840
|
-
* @param {array} mappings 图形字段映射
|
|
6841
|
-
* @param {style} style 样式
|
|
6882
|
+
/**
|
|
6883
|
+
* 饼图
|
|
6884
|
+
*
|
|
6885
|
+
* @class jmPieSeries
|
|
6886
|
+
* @module jmChart
|
|
6887
|
+
* @param {jmChart} chart 当前图表
|
|
6888
|
+
* @param {array} mappings 图形字段映射
|
|
6889
|
+
* @param {style} style 样式
|
|
6842
6890
|
*/
|
|
6843
6891
|
//构造函数
|
|
6844
6892
|
|
|
@@ -6922,10 +6970,10 @@
|
|
|
6922
6970
|
set startAngle(v) {
|
|
6923
6971
|
this.option.startAngle = v;
|
|
6924
6972
|
}
|
|
6925
|
-
/**
|
|
6926
|
-
* 生成序列图描点
|
|
6927
|
-
*
|
|
6928
|
-
* @method createPoints
|
|
6973
|
+
/**
|
|
6974
|
+
* 生成序列图描点
|
|
6975
|
+
*
|
|
6976
|
+
* @method createPoints
|
|
6929
6977
|
*/
|
|
6930
6978
|
|
|
6931
6979
|
|
|
@@ -7015,8 +7063,8 @@
|
|
|
7015
7063
|
maxRadius: p.maxRadius,
|
|
7016
7064
|
minRadius: p.minRadius
|
|
7017
7065
|
});
|
|
7018
|
-
/**
|
|
7019
|
-
* 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
|
|
7066
|
+
/**
|
|
7067
|
+
* 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
|
|
7020
7068
|
*/
|
|
7021
7069
|
|
|
7022
7070
|
p.shape.getLocation = function () {
|
|
@@ -7125,10 +7173,10 @@
|
|
|
7125
7173
|
}
|
|
7126
7174
|
|
|
7127
7175
|
}
|
|
7128
|
-
/**
|
|
7129
|
-
* 生成图例
|
|
7130
|
-
*
|
|
7131
|
-
* @method createLegend
|
|
7176
|
+
/**
|
|
7177
|
+
* 生成图例
|
|
7178
|
+
*
|
|
7179
|
+
* @method createLegend
|
|
7132
7180
|
*/
|
|
7133
7181
|
|
|
7134
7182
|
jmPieSeries.prototype.createLegend = function () {
|
|
@@ -7170,14 +7218,14 @@
|
|
|
7170
7218
|
}
|
|
7171
7219
|
};
|
|
7172
7220
|
|
|
7173
|
-
/**
|
|
7174
|
-
* 图形基类
|
|
7175
|
-
*
|
|
7176
|
-
* @class jmLineSeries
|
|
7177
|
-
* @module jmChart
|
|
7178
|
-
* @param {jmChart} chart 当前图表
|
|
7179
|
-
* @param {array} mappings 图形字段映射
|
|
7180
|
-
* @param {style} style 样式
|
|
7221
|
+
/**
|
|
7222
|
+
* 图形基类
|
|
7223
|
+
*
|
|
7224
|
+
* @class jmLineSeries
|
|
7225
|
+
* @module jmChart
|
|
7226
|
+
* @param {jmChart} chart 当前图表
|
|
7227
|
+
* @param {array} mappings 图形字段映射
|
|
7228
|
+
* @param {style} style 样式
|
|
7181
7229
|
*/
|
|
7182
7230
|
//构造函数
|
|
7183
7231
|
|
|
@@ -7186,11 +7234,11 @@
|
|
|
7186
7234
|
options.style = options.style || options.graph.style.line;
|
|
7187
7235
|
super(options); //this.on('beginDraw', this[PreDrawKey]);
|
|
7188
7236
|
}
|
|
7189
|
-
/**
|
|
7190
|
-
* 绘制图形前 初始化线条
|
|
7191
|
-
*
|
|
7192
|
-
* @method preDraw
|
|
7193
|
-
* @for jmLineSeries
|
|
7237
|
+
/**
|
|
7238
|
+
* 绘制图形前 初始化线条
|
|
7239
|
+
*
|
|
7240
|
+
* @method preDraw
|
|
7241
|
+
* @for jmLineSeries
|
|
7194
7242
|
*/
|
|
7195
7243
|
|
|
7196
7244
|
|
|
@@ -7241,8 +7289,8 @@
|
|
|
7241
7289
|
shapePoints = this.createCurePoints(shapePoints, p);
|
|
7242
7290
|
} // 如果是虚线
|
|
7243
7291
|
else if (this.style.lineType === 'dotted') {
|
|
7244
|
-
|
|
7245
|
-
|
|
7292
|
+
shapePoints = this.createDotLine(shapePoints, p);
|
|
7293
|
+
}
|
|
7246
7294
|
|
|
7247
7295
|
shapePoints.push(p);
|
|
7248
7296
|
this.createItemLabel(p); // 生成关健值标注
|
|
@@ -7325,10 +7373,10 @@
|
|
|
7325
7373
|
|
|
7326
7374
|
return shapePoints;
|
|
7327
7375
|
}
|
|
7328
|
-
/**
|
|
7329
|
-
* 生成图例
|
|
7330
|
-
*
|
|
7331
|
-
* @method createLegend
|
|
7376
|
+
/**
|
|
7377
|
+
* 生成图例
|
|
7378
|
+
*
|
|
7379
|
+
* @method createLegend
|
|
7332
7380
|
*/
|
|
7333
7381
|
|
|
7334
7382
|
|
|
@@ -7417,14 +7465,14 @@
|
|
|
7417
7465
|
|
|
7418
7466
|
}
|
|
7419
7467
|
|
|
7420
|
-
/**
|
|
7421
|
-
* 二条线组成的区域图表
|
|
7422
|
-
*
|
|
7423
|
-
* @class jmStackLineSeries
|
|
7424
|
-
* @module jmChart
|
|
7425
|
-
* @param {jmChart} chart 当前图表
|
|
7426
|
-
* @param {array} mappings 图形字段映射
|
|
7427
|
-
* @param {style} style 样式
|
|
7468
|
+
/**
|
|
7469
|
+
* 二条线组成的区域图表
|
|
7470
|
+
*
|
|
7471
|
+
* @class jmStackLineSeries
|
|
7472
|
+
* @module jmChart
|
|
7473
|
+
* @param {jmChart} chart 当前图表
|
|
7474
|
+
* @param {array} mappings 图形字段映射
|
|
7475
|
+
* @param {style} style 样式
|
|
7428
7476
|
*/
|
|
7429
7477
|
//构造函数
|
|
7430
7478
|
|
|
@@ -7433,11 +7481,11 @@
|
|
|
7433
7481
|
options.style = options.style || options.graph.style.stackLine;
|
|
7434
7482
|
super(options);
|
|
7435
7483
|
}
|
|
7436
|
-
/**
|
|
7437
|
-
* 绘制图形前 初始化线条
|
|
7438
|
-
*
|
|
7439
|
-
* @method preDraw
|
|
7440
|
-
* @for jmLineSeries
|
|
7484
|
+
/**
|
|
7485
|
+
* 绘制图形前 初始化线条
|
|
7486
|
+
*
|
|
7487
|
+
* @method preDraw
|
|
7488
|
+
* @for jmLineSeries
|
|
7441
7489
|
*/
|
|
7442
7490
|
|
|
7443
7491
|
|
|
@@ -7487,9 +7535,9 @@
|
|
|
7487
7535
|
endShapePoints = this.createCurePoints(endShapePoints, p.points[1]);
|
|
7488
7536
|
} // 如果是虚线
|
|
7489
7537
|
else if (this.style.lineType === 'dotted') {
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7538
|
+
startShapePoints = this.createDotLine(startShapePoints, p.points[0]);
|
|
7539
|
+
endShapePoints = this.createDotLine(endShapePoints, p.points[1]);
|
|
7540
|
+
}
|
|
7493
7541
|
|
|
7494
7542
|
startShapePoints.push(p.points[0]);
|
|
7495
7543
|
endShapePoints.push(p.points[1]); // 生成标点的回调
|
|
@@ -7517,10 +7565,10 @@
|
|
|
7517
7565
|
areaEnd.m = false;
|
|
7518
7566
|
this.createArea(areaPoints, false);
|
|
7519
7567
|
}
|
|
7520
|
-
/**
|
|
7521
|
-
* 生成图例
|
|
7522
|
-
*
|
|
7523
|
-
* @method createLegend
|
|
7568
|
+
/**
|
|
7569
|
+
* 生成图例
|
|
7570
|
+
*
|
|
7571
|
+
* @method createLegend
|
|
7524
7572
|
*/
|
|
7525
7573
|
|
|
7526
7574
|
|
|
@@ -7568,15 +7616,114 @@
|
|
|
7568
7616
|
|
|
7569
7617
|
}
|
|
7570
7618
|
|
|
7571
|
-
/**
|
|
7572
|
-
*
|
|
7573
|
-
*
|
|
7574
|
-
* @class
|
|
7575
|
-
* @module jmChart
|
|
7576
|
-
* @param {jmChart} chart 当前图表
|
|
7577
|
-
* @param {
|
|
7578
|
-
* @param {
|
|
7579
|
-
|
|
7619
|
+
/**
|
|
7620
|
+
* K线图
|
|
7621
|
+
*
|
|
7622
|
+
* @class jmCandlestickSeries
|
|
7623
|
+
* @module jmChart
|
|
7624
|
+
* @param {jmChart} chart 当前图表
|
|
7625
|
+
* @param {array} mappings 图形字段映射
|
|
7626
|
+
* @param {style} style 样式
|
|
7627
|
+
*/
|
|
7628
|
+
//构造函数
|
|
7629
|
+
|
|
7630
|
+
class jmCandlestickSeries extends jmSeries {
|
|
7631
|
+
constructor(options) {
|
|
7632
|
+
options.style = options.style || options.graph.style.line;
|
|
7633
|
+
super(options); //this.on('beginDraw', this[PreDrawKey]);
|
|
7634
|
+
}
|
|
7635
|
+
/**
|
|
7636
|
+
* 绘制图形前 初始化线条
|
|
7637
|
+
*
|
|
7638
|
+
* @method preDraw
|
|
7639
|
+
* @for jmLineSeries
|
|
7640
|
+
*/
|
|
7641
|
+
|
|
7642
|
+
|
|
7643
|
+
init() {
|
|
7644
|
+
//生成描点位
|
|
7645
|
+
const {
|
|
7646
|
+
points
|
|
7647
|
+
} = this.initDataPoint(); //去除多余的线条
|
|
7648
|
+
//当数据源线条数比现有的少时,删除多余的线条
|
|
7649
|
+
|
|
7650
|
+
const len = points.length;
|
|
7651
|
+
this.initWidth(len);
|
|
7652
|
+
const w = this.barWidth / 2; //实心处宽度的一半
|
|
7653
|
+
|
|
7654
|
+
for (let i = 0; i < len; i++) {
|
|
7655
|
+
const p = points[i]; //如果当前点无效,则跳致下一点
|
|
7656
|
+
|
|
7657
|
+
if (typeof p.y === 'undefined' || p.y === null) {
|
|
7658
|
+
//prePoint = null;
|
|
7659
|
+
continue;
|
|
7660
|
+
}
|
|
7661
|
+
|
|
7662
|
+
const sp = this.addShape(this.graph.createPath([], p.style));
|
|
7663
|
+
const bl = {
|
|
7664
|
+
x: p.x - w,
|
|
7665
|
+
y: p.points[0].y
|
|
7666
|
+
};
|
|
7667
|
+
const br = {
|
|
7668
|
+
x: p.x + w,
|
|
7669
|
+
y: p.points[0].y
|
|
7670
|
+
};
|
|
7671
|
+
const tl = {
|
|
7672
|
+
x: p.x - w,
|
|
7673
|
+
y: p.points[1].y
|
|
7674
|
+
};
|
|
7675
|
+
const tr = {
|
|
7676
|
+
x: p.x + w,
|
|
7677
|
+
y: p.points[1].y
|
|
7678
|
+
}; // 默认认为是阳线
|
|
7679
|
+
|
|
7680
|
+
let tm = p.points[1];
|
|
7681
|
+
let bm = p.points[0];
|
|
7682
|
+
p.style.stroke = p.style.fill = p.style.masculineColor || 'red'; // 开盘大于收盘,则阴线
|
|
7683
|
+
|
|
7684
|
+
if (p.points[0].yValue > p.points[1].yValue) {
|
|
7685
|
+
p.style.stroke = p.style.fill = p.style.negativeColor || 'green';
|
|
7686
|
+
bl.y = br.y = p.points[1].y;
|
|
7687
|
+
tl.y = tr.y = p.points[0].y;
|
|
7688
|
+
tm = p.points[0];
|
|
7689
|
+
bm = p.points[1];
|
|
7690
|
+
}
|
|
7691
|
+
|
|
7692
|
+
sp.points.push(p.points[2], tm, tl, bl, bm, p.points[3], bm, br, tr, tm, p.points[2]); // 生成关健值标注
|
|
7693
|
+
|
|
7694
|
+
this.emit('onPointCreated', p);
|
|
7695
|
+
}
|
|
7696
|
+
} // 计算实心体宽度
|
|
7697
|
+
|
|
7698
|
+
|
|
7699
|
+
initWidth(count) {
|
|
7700
|
+
//计算每个柱子占宽
|
|
7701
|
+
//每项柱子占宽除以柱子个数,默认最大宽度为30
|
|
7702
|
+
const maxWidth = this.xAxis.width / count;
|
|
7703
|
+
|
|
7704
|
+
if (this.style.barWidth > 0) {
|
|
7705
|
+
this.barWidth = Number(this.style.barWidth);
|
|
7706
|
+
} else {
|
|
7707
|
+
this.barWidth = maxWidth * (this.style.perWidth || 0.4);
|
|
7708
|
+
}
|
|
7709
|
+
|
|
7710
|
+
if (this.barWidth > maxWidth) {
|
|
7711
|
+
this.barWidth = maxWidth;
|
|
7712
|
+
this.barTotalWidth = maxWidth * count;
|
|
7713
|
+
}
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7716
|
+
}
|
|
7717
|
+
|
|
7718
|
+
/**
|
|
7719
|
+
* 轴
|
|
7720
|
+
*
|
|
7721
|
+
* @class jmAxis
|
|
7722
|
+
* @module jmChart
|
|
7723
|
+
* @param {jmChart} chart 当前图表
|
|
7724
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
7725
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
7726
|
+
* @param {object} [style] 样式
|
|
7580
7727
|
*/
|
|
7581
7728
|
|
|
7582
7729
|
class jmMarkLine extends jmLine {
|
|
@@ -7585,8 +7732,8 @@
|
|
|
7585
7732
|
this.visible = false;
|
|
7586
7733
|
this.markLineType = options.type || 'x'; // 为横轴x或纵轴y
|
|
7587
7734
|
|
|
7588
|
-
/**
|
|
7589
|
-
* 当前图形下的所有子图
|
|
7735
|
+
/**
|
|
7736
|
+
* 当前图形下的所有子图
|
|
7590
7737
|
*/
|
|
7591
7738
|
|
|
7592
7739
|
this.shapes = new jmList();
|
|
@@ -7614,14 +7761,13 @@
|
|
|
7614
7761
|
if (this.markLineType === 'y') {
|
|
7615
7762
|
const touchPoints = []; // 命中的数据点
|
|
7616
7763
|
|
|
7617
|
-
let touchChange = false;
|
|
7764
|
+
let touchChange = false; // chartGraph 表示图表层,有可能当前graph为操作层
|
|
7765
|
+
|
|
7766
|
+
const graph = this.graph.chartGraph || this.graph;
|
|
7767
|
+
const isTocuhGraph = graph !== this.graph; // 不在图表图层,在操作图层的情况
|
|
7618
7768
|
|
|
7619
7769
|
try {
|
|
7620
|
-
// chartGraph 表示图表层,有可能当前graph为操作层
|
|
7621
|
-
const graph = this.graph.chartGraph || this.graph;
|
|
7622
|
-
const isTocuhGraph = graph !== this.graph; // 不在图表图层,在操作图层的情况
|
|
7623
7770
|
// 查找最近的X坐标
|
|
7624
|
-
|
|
7625
7771
|
const findX = isTocuhGraph ? this.start.x - graph.chartArea.position.x : this.start.x; // 根据线条数生成标点个数
|
|
7626
7772
|
|
|
7627
7773
|
for (const serie of graph.series) {
|
|
@@ -7650,8 +7796,8 @@
|
|
|
7650
7796
|
serie.lastMarkPoint = point; // 记下最后一次改变的点
|
|
7651
7797
|
// 同时改变下X轴标线的位置,它的Y坐标跟随最后一个命中的线点
|
|
7652
7798
|
|
|
7653
|
-
if (graph && graph.xMarkLine) {
|
|
7654
|
-
graph.xMarkLine.start.y = graph.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
|
|
7799
|
+
if (graph && graph.markLine && graph.markLine.xMarkLine) {
|
|
7800
|
+
graph.markLine.xMarkLine.start.y = graph.markLine.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
|
|
7655
7801
|
}
|
|
7656
7802
|
}
|
|
7657
7803
|
} catch (e) {
|
|
@@ -7666,9 +7812,9 @@
|
|
|
7666
7812
|
}, 10);
|
|
7667
7813
|
}
|
|
7668
7814
|
}
|
|
7669
|
-
/**
|
|
7670
|
-
* 移动标线
|
|
7671
|
-
* @param { object } args 移动事件参数
|
|
7815
|
+
/**
|
|
7816
|
+
* 移动标线
|
|
7817
|
+
* @param { object } args 移动事件参数
|
|
7672
7818
|
*/
|
|
7673
7819
|
|
|
7674
7820
|
|
|
@@ -7732,8 +7878,8 @@
|
|
|
7732
7878
|
this.needUpdate = true;
|
|
7733
7879
|
}
|
|
7734
7880
|
}
|
|
7735
|
-
/**
|
|
7736
|
-
* 中止
|
|
7881
|
+
/**
|
|
7882
|
+
* 中止
|
|
7737
7883
|
*/
|
|
7738
7884
|
|
|
7739
7885
|
|
|
@@ -7744,16 +7890,173 @@
|
|
|
7744
7890
|
|
|
7745
7891
|
}
|
|
7746
7892
|
|
|
7747
|
-
/**
|
|
7748
|
-
*
|
|
7749
|
-
*
|
|
7750
|
-
*
|
|
7751
|
-
* @
|
|
7752
|
-
* @
|
|
7753
|
-
* @param {
|
|
7893
|
+
/**
|
|
7894
|
+
* 轴
|
|
7895
|
+
*
|
|
7896
|
+
* @class jmMarkLineManager
|
|
7897
|
+
* @module jmChart
|
|
7898
|
+
* @param {jmChart} chart 当前图表
|
|
7899
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
7900
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
7901
|
+
* @param {object} [style] 样式
|
|
7902
|
+
*/
|
|
7903
|
+
|
|
7904
|
+
class jmMarkLineManager {
|
|
7905
|
+
constructor(chart) {
|
|
7906
|
+
this.chart = chart;
|
|
7907
|
+
this.init(chart);
|
|
7908
|
+
} // 初始化
|
|
7909
|
+
|
|
7910
|
+
|
|
7911
|
+
init(chart) {
|
|
7912
|
+
const graph = chart.touchGraph || chart;
|
|
7913
|
+
graph.on('beginDraw', () => {
|
|
7914
|
+
// 重置标线,会处理小圆圈问题
|
|
7915
|
+
this.xMarkLine && this.xMarkLine.init();
|
|
7916
|
+
this.yMarkLine && this.yMarkLine.init();
|
|
7917
|
+
});
|
|
7918
|
+
|
|
7919
|
+
if (chart.style.markLine) {
|
|
7920
|
+
// 生成标线,可以跟随鼠标或手指滑动
|
|
7921
|
+
if (chart.style.markLine && chart.style.markLine.x) {
|
|
7922
|
+
this.xMarkLine = graph.createShape(jmMarkLine, {
|
|
7923
|
+
type: 'x',
|
|
7924
|
+
style: chart.style.markLine
|
|
7925
|
+
});
|
|
7926
|
+
const area = graph.chartArea || graph;
|
|
7927
|
+
area.children.add(this.xMarkLine);
|
|
7928
|
+
}
|
|
7929
|
+
|
|
7930
|
+
if (chart.style.markLine && chart.style.markLine.y) {
|
|
7931
|
+
this.yMarkLine = graph.createShape(jmMarkLine, {
|
|
7932
|
+
type: 'y',
|
|
7933
|
+
style: chart.style.markLine
|
|
7934
|
+
});
|
|
7935
|
+
const area = graph.chartArea || graph;
|
|
7936
|
+
area.children.add(this.yMarkLine);
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
|
|
7940
|
+
|
|
7941
|
+
let longtapHandler = 0;
|
|
7942
|
+
let touchStartPos = {
|
|
7943
|
+
x: 0,
|
|
7944
|
+
y: 0
|
|
7945
|
+
};
|
|
7946
|
+
graph.on('mousedown touchstart', args => {
|
|
7947
|
+
// 如果长按才启用
|
|
7948
|
+
if (chart.style.markLine.longtap) {
|
|
7949
|
+
longtap = 1;
|
|
7950
|
+
longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
|
|
7951
|
+
let tapStartTime = Date.now();
|
|
7952
|
+
|
|
7953
|
+
const reqFun = () => {
|
|
7954
|
+
const elapsed = Date.now() - tapStartTime;
|
|
7955
|
+
|
|
7956
|
+
if (longtap === 1 || longtap === 2) {
|
|
7957
|
+
// 如果还未过一定时间,则继续等待
|
|
7958
|
+
if (elapsed < 500) {
|
|
7959
|
+
longtapHandler = graph.utils.requestAnimationFrame(reqFun);
|
|
7960
|
+
return;
|
|
7961
|
+
}
|
|
7962
|
+
|
|
7963
|
+
longtap = 2;
|
|
7964
|
+
this.startMove(args);
|
|
7965
|
+
chart.emit('marklinelongtapstart', args);
|
|
7966
|
+
}
|
|
7967
|
+
}; // 如果一定时间后还没有取消,则表示长按了
|
|
7968
|
+
|
|
7969
|
+
|
|
7970
|
+
longtapHandler = graph.utils.requestAnimationFrame(reqFun); //args.event.stopPropagation();
|
|
7971
|
+
|
|
7972
|
+
args.event.preventDefault(); // 阻止默认行为
|
|
7973
|
+
} else {
|
|
7974
|
+
this.startMove(args);
|
|
7975
|
+
}
|
|
7976
|
+
|
|
7977
|
+
args.longtap = longtap;
|
|
7978
|
+
touchStartPos = args.position;
|
|
7979
|
+
}); // 移动标线
|
|
7980
|
+
|
|
7981
|
+
graph.on('mousemove touchmove', args => {
|
|
7982
|
+
const ox = args.position.x - touchStartPos.x;
|
|
7983
|
+
const oy = args.position.y - touchStartPos.y;
|
|
7984
|
+
const offpos = Math.sqrt(ox * ox + oy * oy);
|
|
7985
|
+
if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
|
|
7986
|
+
|
|
7987
|
+
args.longtap = longtap;
|
|
7988
|
+
this.move(args);
|
|
7989
|
+
}); // 取消移动
|
|
7990
|
+
|
|
7991
|
+
graph.on('mouseup touchend touchcancel touchleave', args => {
|
|
7992
|
+
longtap = 0;
|
|
7993
|
+
this.endMove(args);
|
|
7994
|
+
});
|
|
7995
|
+
}
|
|
7996
|
+
} // 开始移动标线
|
|
7997
|
+
|
|
7998
|
+
|
|
7999
|
+
startMove(args, markLineType = 'xy') {
|
|
8000
|
+
if (this.xMarkLine && markLineType.includes('x')) {
|
|
8001
|
+
this.xMarkLine.visible = true;
|
|
8002
|
+
this.xMarkLine.move(args);
|
|
8003
|
+
}
|
|
8004
|
+
|
|
8005
|
+
if (this.yMarkLine && markLineType.includes('y')) {
|
|
8006
|
+
this.yMarkLine.visible = true;
|
|
8007
|
+
this.yMarkLine.move(args);
|
|
8008
|
+
}
|
|
8009
|
+
|
|
8010
|
+
if (!args.cancel) this.chart.emit('marklinestartmove', args);
|
|
8011
|
+
} // 移动标线
|
|
8012
|
+
|
|
8013
|
+
|
|
8014
|
+
move(args) {
|
|
8015
|
+
let moved = false;
|
|
8016
|
+
|
|
8017
|
+
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
8018
|
+
this.xMarkLine.move(args);
|
|
8019
|
+
moved = true;
|
|
8020
|
+
}
|
|
8021
|
+
|
|
8022
|
+
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
8023
|
+
this.yMarkLine.move(args);
|
|
8024
|
+
moved = true;
|
|
8025
|
+
}
|
|
8026
|
+
|
|
8027
|
+
if (moved) {
|
|
8028
|
+
args.event.stopPropagation();
|
|
8029
|
+
args.event.preventDefault(); // 阻止默认行为
|
|
8030
|
+
|
|
8031
|
+
if (!args.cancel) this.chart.emit('marklinemove', args);
|
|
8032
|
+
}
|
|
8033
|
+
} // 终止动移
|
|
8034
|
+
|
|
8035
|
+
|
|
8036
|
+
endMove(args) {
|
|
8037
|
+
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
8038
|
+
this.xMarkLine.cancel(args);
|
|
8039
|
+
}
|
|
8040
|
+
|
|
8041
|
+
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
8042
|
+
this.yMarkLine.cancel(args);
|
|
8043
|
+
}
|
|
8044
|
+
|
|
8045
|
+
if (!args.cancel) this.chart.emit('marklineendmove', args);
|
|
8046
|
+
}
|
|
8047
|
+
|
|
8048
|
+
}
|
|
8049
|
+
|
|
8050
|
+
/**
|
|
8051
|
+
* jm图表组件
|
|
8052
|
+
* option参数:graph=jmgraph
|
|
8053
|
+
*
|
|
8054
|
+
* @class jmChart
|
|
8055
|
+
* @module jmChart
|
|
8056
|
+
* @param {element} container 图表容器
|
|
7754
8057
|
*/
|
|
7755
8058
|
|
|
7756
|
-
class jmChart extends jmGraph
|
|
8059
|
+
class jmChart extends jmGraph {
|
|
7757
8060
|
constructor(container, options) {
|
|
7758
8061
|
options = options || {};
|
|
7759
8062
|
const enableAnimate = !!options.enableAnimate;
|
|
@@ -7779,13 +8082,13 @@
|
|
|
7779
8082
|
|
|
7780
8083
|
this.createTouchGraph(this.container, options);
|
|
7781
8084
|
}
|
|
7782
|
-
/**
|
|
7783
|
-
* 绑定的数据源
|
|
8085
|
+
/**
|
|
8086
|
+
* 绑定的数据源
|
|
7784
8087
|
*/
|
|
7785
8088
|
|
|
7786
8089
|
|
|
7787
|
-
/**
|
|
7788
|
-
* 是否启用动画
|
|
8090
|
+
/**
|
|
8091
|
+
* 是否启用动画
|
|
7789
8092
|
*/
|
|
7790
8093
|
get enableAnimate() {
|
|
7791
8094
|
if (typeof this.option.enableAnimate !== 'undefined') return !!this.option.enableAnimate;else {
|
|
@@ -7796,8 +8099,8 @@
|
|
|
7796
8099
|
set enableAnimate(v) {
|
|
7797
8100
|
this.option.enableAnimate = v;
|
|
7798
8101
|
}
|
|
7799
|
-
/**
|
|
7800
|
-
* Y轴的基线 默认是0
|
|
8102
|
+
/**
|
|
8103
|
+
* Y轴的基线 默认是0
|
|
7801
8104
|
*/
|
|
7802
8105
|
|
|
7803
8106
|
|
|
@@ -7811,11 +8114,11 @@
|
|
|
7811
8114
|
|
|
7812
8115
|
|
|
7813
8116
|
init(options) {
|
|
7814
|
-
/**
|
|
7815
|
-
* 绘图区域
|
|
7816
|
-
*
|
|
7817
|
-
* @property chartArea
|
|
7818
|
-
* @type jmControl
|
|
8117
|
+
/**
|
|
8118
|
+
* 绘图区域
|
|
8119
|
+
*
|
|
8120
|
+
* @property chartArea
|
|
8121
|
+
* @type jmControl
|
|
7819
8122
|
*/
|
|
7820
8123
|
if (!this.chartArea) {
|
|
7821
8124
|
this.chartArea = this.createShape('rect', {
|
|
@@ -7827,11 +8130,11 @@
|
|
|
7827
8130
|
});
|
|
7828
8131
|
this.children.add(this.chartArea);
|
|
7829
8132
|
}
|
|
7830
|
-
/**
|
|
7831
|
-
* 图例
|
|
7832
|
-
*
|
|
7833
|
-
* @property legend
|
|
7834
|
-
* @type jmLegend
|
|
8133
|
+
/**
|
|
8134
|
+
* 图例
|
|
8135
|
+
*
|
|
8136
|
+
* @property legend
|
|
8137
|
+
* @type jmLegend
|
|
7835
8138
|
*/
|
|
7836
8139
|
|
|
7837
8140
|
|
|
@@ -7843,11 +8146,11 @@
|
|
|
7843
8146
|
if (options.legendVisible === false) {
|
|
7844
8147
|
this.legend.visible = false;
|
|
7845
8148
|
}
|
|
7846
|
-
/**
|
|
7847
|
-
* 图表提示控件
|
|
7848
|
-
*
|
|
7849
|
-
* @property tooltip
|
|
7850
|
-
* @type jmTooltip
|
|
8149
|
+
/**
|
|
8150
|
+
* 图表提示控件
|
|
8151
|
+
*
|
|
8152
|
+
* @property tooltip
|
|
8153
|
+
* @type jmTooltip
|
|
7851
8154
|
*/
|
|
7852
8155
|
//this.tooltip = this.graph.createShape('tooltip',{style:this.style.tooltip});
|
|
7853
8156
|
//this.chartArea.children.add(this.tooltip);
|
|
@@ -7865,84 +8168,36 @@
|
|
|
7865
8168
|
container && (container.style.position = 'relative');
|
|
7866
8169
|
options = this.utils.clone(options, {
|
|
7867
8170
|
autoRefresh: true
|
|
7868
|
-
}, true);
|
|
7869
|
-
let graph = this.touchGraph = this; // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
|
|
8171
|
+
}, true); // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
|
|
7870
8172
|
// isWXMiniApp 非微信小程序下才能创建
|
|
7871
8173
|
|
|
7872
|
-
if (!
|
|
8174
|
+
if (!this.isWXMiniApp && container && options.touchGraph) {
|
|
7873
8175
|
let cn = document.createElement('canvas');
|
|
7874
8176
|
cn.width = container.offsetWidth || container.clientWidth;
|
|
7875
8177
|
cn.height = container.offsetHeight || container.clientHeight;
|
|
7876
8178
|
cn.style.position = 'absolute';
|
|
7877
8179
|
cn.style.top = 0;
|
|
7878
8180
|
cn.style.left = 0;
|
|
7879
|
-
this.touchGraph =
|
|
8181
|
+
this.touchGraph = new jmGraph(cn, options);
|
|
7880
8182
|
container.appendChild(cn);
|
|
7881
8183
|
this.touchGraph.chartGraph = this;
|
|
7882
8184
|
this.on('propertyChange', (name, args) => {
|
|
7883
8185
|
if (['width', 'height'].includes(name)) {
|
|
7884
8186
|
this.touchGraph[name] = args.newValue / this.devicePixelRatio;
|
|
7885
8187
|
}
|
|
7886
|
-
});
|
|
7887
|
-
}
|
|
8188
|
+
}); // 把上层canvse事件传递给绘图层对象
|
|
7888
8189
|
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
// 重置标线,会处理小圆圈问题
|
|
7892
|
-
this.xMarkLine && this.xMarkLine.init();
|
|
7893
|
-
this.yMarkLine && this.yMarkLine.init();
|
|
7894
|
-
}); // 生成标线,可以跟随鼠标或手指滑动
|
|
8190
|
+
this.touchGraph.on('mousedown touchstart mousemove touchmove mouseup touchend touchcancel touchleave', args => {
|
|
8191
|
+
const eventName = args.event.eventName || args.event.type;
|
|
7895
8192
|
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
type: 'x',
|
|
7899
|
-
style: this.style.markLine
|
|
7900
|
-
});
|
|
7901
|
-
const area = graph.chartArea || graph;
|
|
7902
|
-
area.children.add(this.xMarkLine);
|
|
7903
|
-
}
|
|
7904
|
-
|
|
7905
|
-
if (this.style.markLine && this.style.markLine.y) {
|
|
7906
|
-
this.yMarkLine = graph.createShape(jmMarkLine, {
|
|
7907
|
-
type: 'y',
|
|
7908
|
-
style: this.style.markLine
|
|
7909
|
-
});
|
|
7910
|
-
const area = graph.chartArea || graph;
|
|
7911
|
-
area.children.add(this.yMarkLine);
|
|
7912
|
-
}
|
|
7913
|
-
|
|
7914
|
-
graph.on('mousedown touchstart', args => {
|
|
7915
|
-
if (this.xMarkLine) {
|
|
7916
|
-
this.xMarkLine.visible = true;
|
|
7917
|
-
this.xMarkLine.move(args);
|
|
7918
|
-
}
|
|
7919
|
-
|
|
7920
|
-
if (this.yMarkLine) {
|
|
7921
|
-
this.yMarkLine.visible = true;
|
|
7922
|
-
this.yMarkLine.move(args);
|
|
8193
|
+
if (eventName) {
|
|
8194
|
+
this.emit(eventName, args);
|
|
7923
8195
|
}
|
|
7924
|
-
});
|
|
7925
|
-
|
|
7926
|
-
graph.on('mousemove touchmove', args => {
|
|
7927
|
-
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
7928
|
-
this.xMarkLine.move(args);
|
|
7929
|
-
}
|
|
7930
|
-
|
|
7931
|
-
if (this.yMarkLine && this.yMarkLine.visible) {
|
|
7932
|
-
this.yMarkLine.move(args);
|
|
7933
|
-
}
|
|
7934
|
-
}); // 取消移动
|
|
8196
|
+
});
|
|
8197
|
+
} // 初始化标线
|
|
7935
8198
|
|
|
7936
|
-
graph.on('mouseup touchend touchcancel touchleave', args => {
|
|
7937
|
-
if (this.xMarkLine && this.xMarkLine.visible) {
|
|
7938
|
-
this.xMarkLine.cancel(args);
|
|
7939
|
-
}
|
|
7940
8199
|
|
|
7941
|
-
|
|
7942
|
-
this.yMarkLine.cancel(args);
|
|
7943
|
-
}
|
|
7944
|
-
});
|
|
7945
|
-
}
|
|
8200
|
+
this.markLine = new jmMarkLineManager(this);
|
|
7946
8201
|
} // 重置整个图表
|
|
7947
8202
|
|
|
7948
8203
|
|
|
@@ -7975,11 +8230,11 @@
|
|
|
7975
8230
|
delete this.yAxises;
|
|
7976
8231
|
}
|
|
7977
8232
|
}
|
|
7978
|
-
/**
|
|
7979
|
-
* 获取颜色
|
|
7980
|
-
*
|
|
7981
|
-
* @method getColor
|
|
7982
|
-
* @param {int} index 颜色索引
|
|
8233
|
+
/**
|
|
8234
|
+
* 获取颜色
|
|
8235
|
+
*
|
|
8236
|
+
* @method getColor
|
|
8237
|
+
* @param {int} index 颜色索引
|
|
7983
8238
|
*/
|
|
7984
8239
|
|
|
7985
8240
|
|
|
@@ -7991,11 +8246,11 @@
|
|
|
7991
8246
|
|
|
7992
8247
|
return this.style.chartColors[index];
|
|
7993
8248
|
}
|
|
7994
|
-
/**
|
|
7995
|
-
* 绘制当前图表
|
|
7996
|
-
* 先绘制轴等基础信息
|
|
7997
|
-
*
|
|
7998
|
-
* @method beginDraw
|
|
8249
|
+
/**
|
|
8250
|
+
* 绘制当前图表
|
|
8251
|
+
* 先绘制轴等基础信息
|
|
8252
|
+
*
|
|
8253
|
+
* @method beginDraw
|
|
7999
8254
|
*/
|
|
8000
8255
|
|
|
8001
8256
|
|
|
@@ -8060,10 +8315,10 @@
|
|
|
8060
8315
|
serie.init && serie.init();
|
|
8061
8316
|
}); //console.log('beginDraw4', Date.now() - startTime);
|
|
8062
8317
|
}
|
|
8063
|
-
/**
|
|
8064
|
-
* 重新定位区域的位置
|
|
8065
|
-
*
|
|
8066
|
-
* @method resetAreaPosition
|
|
8318
|
+
/**
|
|
8319
|
+
* 重新定位区域的位置
|
|
8320
|
+
*
|
|
8321
|
+
* @method resetAreaPosition
|
|
8067
8322
|
*/
|
|
8068
8323
|
|
|
8069
8324
|
|
|
@@ -8075,15 +8330,15 @@
|
|
|
8075
8330
|
this.chartArea.width = w;
|
|
8076
8331
|
this.chartArea.height = h;
|
|
8077
8332
|
}
|
|
8078
|
-
/**
|
|
8079
|
-
* 创建轴
|
|
8080
|
-
*
|
|
8081
|
-
* @method createAxis
|
|
8082
|
-
* @for jmChart
|
|
8083
|
-
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
8084
|
-
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
8085
|
-
* @param {object} [style] 样式
|
|
8086
|
-
* @return {axis} 轴
|
|
8333
|
+
/**
|
|
8334
|
+
* 创建轴
|
|
8335
|
+
*
|
|
8336
|
+
* @method createAxis
|
|
8337
|
+
* @for jmChart
|
|
8338
|
+
* @param {string} [type] 轴类型(x/y/radar),默认为x
|
|
8339
|
+
* @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
|
|
8340
|
+
* @param {object} [style] 样式
|
|
8341
|
+
* @return {axis} 轴
|
|
8087
8342
|
*/
|
|
8088
8343
|
|
|
8089
8344
|
|
|
@@ -8095,12 +8350,12 @@
|
|
|
8095
8350
|
this.children.add(axis);
|
|
8096
8351
|
return axis;
|
|
8097
8352
|
}
|
|
8098
|
-
/**
|
|
8099
|
-
* 生成X轴
|
|
8100
|
-
*
|
|
8101
|
-
* @method createXAxis
|
|
8102
|
-
* @param {string} x轴的数据类型(string/number/date)
|
|
8103
|
-
* @param {bool} 是否从0开始
|
|
8353
|
+
/**
|
|
8354
|
+
* 生成X轴
|
|
8355
|
+
*
|
|
8356
|
+
* @method createXAxis
|
|
8357
|
+
* @param {string} x轴的数据类型(string/number/date)
|
|
8358
|
+
* @param {bool} 是否从0开始
|
|
8104
8359
|
*/
|
|
8105
8360
|
|
|
8106
8361
|
|
|
@@ -8127,13 +8382,13 @@
|
|
|
8127
8382
|
|
|
8128
8383
|
return this.xAxis;
|
|
8129
8384
|
}
|
|
8130
|
-
/**
|
|
8131
|
-
* 生成Y轴
|
|
8132
|
-
*
|
|
8133
|
-
* @method createYAxis
|
|
8134
|
-
* @param {int} Y轴索引,可以创建多个Y轴
|
|
8135
|
-
* @param {string} y轴的数据类型(string/number/date)
|
|
8136
|
-
* @param {bool} 是否从0开始
|
|
8385
|
+
/**
|
|
8386
|
+
* 生成Y轴
|
|
8387
|
+
*
|
|
8388
|
+
* @method createYAxis
|
|
8389
|
+
* @param {int} Y轴索引,可以创建多个Y轴
|
|
8390
|
+
* @param {string} y轴的数据类型(string/number/date)
|
|
8391
|
+
* @param {bool} 是否从0开始
|
|
8137
8392
|
*/
|
|
8138
8393
|
|
|
8139
8394
|
|
|
@@ -8162,14 +8417,14 @@
|
|
|
8162
8417
|
var yaxis = this.yAxises[options.index] || (this.yAxises[options.index] = this.createAxis(options));
|
|
8163
8418
|
return yaxis;
|
|
8164
8419
|
}
|
|
8165
|
-
/**
|
|
8166
|
-
* 创建图形
|
|
8167
|
-
*
|
|
8168
|
-
* @method createSeries
|
|
8169
|
-
* @for jmChart
|
|
8170
|
-
* @param {string} [type] 图类型,(line/bar/pie/radar)
|
|
8171
|
-
* @param {object} [options] 生成图表选项 {xField, yField, index}
|
|
8172
|
-
* @return {series} 图形
|
|
8420
|
+
/**
|
|
8421
|
+
* 创建图形
|
|
8422
|
+
*
|
|
8423
|
+
* @method createSeries
|
|
8424
|
+
* @for jmChart
|
|
8425
|
+
* @param {string} [type] 图类型,(line/bar/pie/radar)
|
|
8426
|
+
* @param {object} [options] 生成图表选项 {xField, yField, index}
|
|
8427
|
+
* @return {series} 图形
|
|
8173
8428
|
*/
|
|
8174
8429
|
|
|
8175
8430
|
|
|
@@ -8180,7 +8435,8 @@
|
|
|
8180
8435
|
'bar': jmBarSeries,
|
|
8181
8436
|
'stackBar': jmStackBarSeries,
|
|
8182
8437
|
'pie': jmPieSeries,
|
|
8183
|
-
'stackLine': jmStackLineSeries
|
|
8438
|
+
'stackLine': jmStackLineSeries,
|
|
8439
|
+
'candlestick': jmCandlestickSeries
|
|
8184
8440
|
};
|
|
8185
8441
|
} //默认样式为类型对应的样式
|
|
8186
8442
|
|
|
@@ -8323,10 +8579,12 @@
|
|
|
8323
8579
|
template: `<div ref="jmChartContainer" :style="{width: width, height: height}"></div>`
|
|
8324
8580
|
};
|
|
8325
8581
|
|
|
8326
|
-
exports
|
|
8582
|
+
exports['default'] = jmChart;
|
|
8327
8583
|
exports.jmChart = jmChart;
|
|
8328
8584
|
exports.vChart = vchart;
|
|
8329
8585
|
|
|
8586
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8587
|
+
|
|
8330
8588
|
return exports;
|
|
8331
8589
|
|
|
8332
8590
|
}({}));
|