jmchart 1.1.81 → 1.1.90

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