jmchart 1.1.81 → 1.1.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- System.register([], (function (exports) {
1
+ System.register([], function (exports) {
2
2
  'use strict';
3
3
  return {
4
- execute: (function () {
4
+ execute: function () {
5
5
 
6
6
  function _defineProperty(obj, key, value) {
7
7
  if (key in obj) {
@@ -343,7 +343,7 @@ System.register([], (function (exports) {
343
343
  let isTouch = false;
344
344
  let touches = evt.changedTouches || evt.targetTouches || evt.touches;
345
345
  let target = evt.target || evt.srcElement;
346
- if(touches) {
346
+ if(touches && touches.length) {
347
347
  evt = touches[0];//兼容touch事件
348
348
  if(!evt.target) evt.target = target;
349
349
  isTouch = true;
@@ -876,6 +876,23 @@ System.register([], (function (exports) {
876
876
  }
877
877
  return r;
878
878
  }
879
+ // window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
880
+ static requestAnimationFrame(callback) {
881
+ if(typeof requestAnimationFrame === 'undefined') {
882
+ return setTimeout(callback, 20);
883
+ }
884
+ else {
885
+ return requestAnimationFrame(callback);
886
+ }
887
+ }
888
+ static cancelAnimationFrame(handler) {
889
+ if(typeof requestAnimationFrame === 'undefined') {
890
+ return clearTimeout(handler);
891
+ }
892
+ else {
893
+ return cancelAnimationFrame(handler);
894
+ }
895
+ }
879
896
  }
880
897
 
881
898
  /**
@@ -4341,6 +4358,7 @@ System.register([], (function (exports) {
4341
4358
 
4342
4359
  touchStart(evt) {
4343
4360
  evt = evt || window.event;
4361
+ evt.eventName = 'touchstart';
4344
4362
  this.container.raiseEvent('touchstart',evt);
4345
4363
  let t = evt.target || evt.srcElement;
4346
4364
  if(t == this.target) {
@@ -4351,6 +4369,7 @@ System.register([], (function (exports) {
4351
4369
 
4352
4370
  touchMove(evt) {
4353
4371
  evt = evt || window.event;
4372
+ evt.eventName = 'touchmove';
4354
4373
  this.container.raiseEvent('touchmove',evt);
4355
4374
  let t = evt.target || evt.srcElement;
4356
4375
  if(t == this.target) {
@@ -4361,6 +4380,7 @@ System.register([], (function (exports) {
4361
4380
 
4362
4381
  touchEnd(evt) {
4363
4382
  evt = evt || window.event;
4383
+ evt.eventName = 'touchend';
4364
4384
 
4365
4385
  this.container.raiseEvent('touchend',evt);
4366
4386
  let t = evt.target || evt.srcElement;
@@ -4372,6 +4392,7 @@ System.register([], (function (exports) {
4372
4392
 
4373
4393
  touchCancel(evt) {
4374
4394
  evt = evt || window.event;
4395
+ evt.eventName = 'touchcancel';
4375
4396
 
4376
4397
  this.container.raiseEvent('touchcancel',evt);
4377
4398
  let t = evt.target || evt.srcElement;
@@ -4412,6 +4433,7 @@ System.register([], (function (exports) {
4412
4433
 
4413
4434
  this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousedown',function(evt) {
4414
4435
  evt = evt || window.event;
4436
+ evt.eventName = 'mousedown';
4415
4437
  container.raiseEvent('mousedown',evt);
4416
4438
  //if(r === false) {
4417
4439
  //if(evt.preventDefault) evt.preventDefault();
@@ -4421,6 +4443,7 @@ System.register([], (function (exports) {
4421
4443
 
4422
4444
  this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousemove',function(evt) {
4423
4445
  evt = evt || window.event;
4446
+ evt.eventName = 'mousemove';
4424
4447
  let target = evt.target || evt.srcElement;
4425
4448
  if(target == canvas) {
4426
4449
  container.raiseEvent('mousemove',evt);
@@ -4432,19 +4455,23 @@ System.register([], (function (exports) {
4432
4455
  });
4433
4456
 
4434
4457
  this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mouseover',function(evt) {
4435
- evt = evt || window.event;
4458
+ evt = evt || window.event;
4459
+ evt.eventName = 'mouseover';
4436
4460
  container.raiseEvent('mouseover',evt);
4437
4461
  });
4438
4462
  this.eventEvents['mouseleave'] = jmUtils.bindEvent(this.target,'mouseleave',function(evt) {
4439
- evt = evt || window.event;
4463
+ evt = evt || window.event;
4464
+ evt.eventName = 'mouseleave';
4440
4465
  container.raiseEvent('mouseleave',evt);
4441
4466
  });
4442
4467
  this.eventEvents['mouseout'] = jmUtils.bindEvent(this.target,'mouseout',function(evt) {
4443
- evt = evt || window.event;
4468
+ evt = evt || window.event;
4469
+ evt.eventName = 'mouseout';
4444
4470
  container.raiseEvent('mouseout',evt);
4445
4471
  });
4446
4472
  doc && (this.eventEvents['mouseup'] = jmUtils.bindEvent(doc,'mouseup',function(evt) {
4447
- evt = evt || window.event;
4473
+ evt = evt || window.event;
4474
+ evt.eventName = 'mouseup';
4448
4475
  //let target = evt.target || evt.srcElement;
4449
4476
  //if(target == canvas) {
4450
4477
  let r = container.raiseEvent('mouseup',evt);
@@ -4457,33 +4484,40 @@ System.register([], (function (exports) {
4457
4484
 
4458
4485
  this.eventEvents['dblclick'] = jmUtils.bindEvent(this.target,'dblclick',function(evt) {
4459
4486
  evt = evt || window.event;
4487
+ evt.eventName = 'dblclick';
4460
4488
  container.raiseEvent('dblclick',evt);
4461
4489
  });
4462
4490
  this.eventEvents['click'] = jmUtils.bindEvent(this.target,'click',function(evt) {
4463
4491
  evt = evt || window.event;
4492
+ evt.eventName = 'click';
4464
4493
  container.raiseEvent('click',evt);
4465
4494
  });
4466
4495
 
4467
4496
  doc && (this.eventEvents['resize'] = jmUtils.bindEvent(doc,'resize',function(evt) {
4468
4497
  evt = evt || window.event;
4498
+ evt.eventName = 'resize';
4469
4499
  return container.raiseEvent('resize',evt);
4470
4500
  }));
4471
4501
 
4472
4502
  // passive: false 为了让浏览器不告警并且preventDefault有效
4473
4503
  // 另一种处理:touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。
4474
4504
  this.eventEvents['touchstart'] = jmUtils.bindEvent(this.target,'touchstart', function(evt) {
4505
+ evt.eventName = 'touchstart';
4475
4506
  return instance.touchStart(evt);
4476
4507
  },{ passive: false });
4477
4508
 
4478
4509
  this.eventEvents['touchmove'] = jmUtils.bindEvent(this.target,'touchmove', function(evt) {
4510
+ evt.eventName = 'touchmove';
4479
4511
  return instance.touchMove(evt);
4480
4512
  },{ passive: false });
4481
4513
 
4482
4514
  doc && (this.eventEvents['touchend'] = jmUtils.bindEvent(doc,'touchend', function(evt) {
4515
+ evt.eventName = 'touchend';
4483
4516
  return instance.touchEnd(evt);
4484
4517
  },{ passive: false }));
4485
4518
 
4486
4519
  doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'touchcancel', function(evt) {
4520
+ evt.eventName = 'touchcancel';
4487
4521
  return instance.touchCancel(evt);
4488
4522
  },{ passive: false }));
4489
4523
  }
@@ -4538,7 +4572,7 @@ System.register([], (function (exports) {
4538
4572
  return true;
4539
4573
  };
4540
4574
 
4541
- doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'keypress',function(evt) {
4575
+ doc && (this.eventEvents['keypress'] = jmUtils.bindEvent(doc,'keypress',function(evt) {
4542
4576
  evt = evt || window.event;
4543
4577
  if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
4544
4578
  let r = container.raiseEvent('keypress',evt);
@@ -4546,7 +4580,7 @@ System.register([], (function (exports) {
4546
4580
  evt.preventDefault();
4547
4581
  return r;
4548
4582
  }));
4549
- doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'keydown',function(evt) {
4583
+ doc && (this.eventEvents['keydown'] = jmUtils.bindEvent(doc,'keydown',function(evt) {
4550
4584
  evt = evt || window.event;
4551
4585
  if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
4552
4586
  let r = container.raiseEvent('keydown',evt);
@@ -4554,7 +4588,7 @@ System.register([], (function (exports) {
4554
4588
  evt.preventDefault();
4555
4589
  return r;
4556
4590
  }));
4557
- doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'keyup',function(evt) {
4591
+ doc && (this.eventEvents['keyup'] = jmUtils.bindEvent(doc,'keyup',function(evt) {
4558
4592
  evt = evt || window.event;
4559
4593
  if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
4560
4594
  let r = container.raiseEvent('keyup',evt);
@@ -4594,7 +4628,7 @@ System.register([], (function (exports) {
4594
4628
  }
4595
4629
 
4596
4630
  option = option || {};
4597
-
4631
+ option.mode = option.mode || '2d'; // webgl | 2d
4598
4632
  option.interactive = true;
4599
4633
 
4600
4634
  super(option, 'jmGraph');
@@ -4634,8 +4668,7 @@ System.register([], (function (exports) {
4634
4668
  }
4635
4669
  else {
4636
4670
  this.container = canvas.parentElement;
4637
- }
4638
-
4671
+ }
4639
4672
  this.context = canvas.getContext('2d');
4640
4673
  }
4641
4674
  this.canvas = canvas;
@@ -5063,26 +5096,19 @@ System.register([], (function (exports) {
5063
5096
  if(this.___isAutoRefreshing) return;
5064
5097
  const self = this;
5065
5098
  this.___isAutoRefreshing = true;
5066
- let requestAnimationFrameFun = null;
5067
- if(typeof requestAnimationFrame === 'undefined') {
5068
- requestAnimationFrameFun = (fun) => {
5069
- if(this.__requestAnimationFrameFunHandler) clearTimeout(this.__requestAnimationFrameFunHandler);
5070
- this.__requestAnimationFrameFunHandler = setTimeout(fun, 20);
5071
- };
5072
- }
5073
- else {
5074
- requestAnimationFrameFun = requestAnimationFrame;
5075
- }
5099
+
5076
5100
  function update() {
5077
5101
  if(self.destoryed) {
5078
5102
  self.___isAutoRefreshing = false;
5079
5103
  return;// 已销毁
5080
5104
  }
5081
5105
  if(self.needUpdate) self.redraw();
5082
- requestAnimationFrameFun(update);
5106
+ self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5107
+ self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5083
5108
  if(callback) callback();
5084
5109
  }
5085
- requestAnimationFrameFun(update);
5110
+ self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5111
+ self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5086
5112
  return this;
5087
5113
  }
5088
5114
 
@@ -5135,12 +5161,12 @@ System.register([], (function (exports) {
5135
5161
  }
5136
5162
  }
5137
5163
 
5138
- /**
5139
- * 基础样式
5140
- *
5141
- * @class jmChartStyle
5142
- * @module jmChart
5143
- * @static
5164
+ /**
5165
+ * 基础样式
5166
+ *
5167
+ * @class jmChartStyle
5168
+ * @module jmChart
5169
+ * @static
5144
5170
  */
5145
5171
  var defaultStyle = {
5146
5172
  layout: 'normal',
@@ -5276,13 +5302,13 @@ System.register([], (function (exports) {
5276
5302
  // 图形样式集
5277
5303
  chartColors: ['#249FDA', '#EA3B7C', '#8EBC00', '#309B46', '#4B507E', '#D8E404', '#EB792A', '#A00DA0'],
5278
5304
 
5279
- /*tooltip: {
5280
- 'background-color': 'rgb(255,255,255)',
5281
- 'padding':'4px',
5282
- 'opacity':'0.8',
5283
- 'border':'1px solid #000',
5284
- 'box-shadow': '0 0 3px #000',
5285
- 'border-radius': '6px'
5305
+ /*tooltip: {
5306
+ 'background-color': 'rgb(255,255,255)',
5307
+ 'padding':'4px',
5308
+ 'opacity':'0.8',
5309
+ 'border':'1px solid #000',
5310
+ 'box-shadow': '0 0 3px #000',
5311
+ 'border-radius': '6px'
5286
5312
  },*/
5287
5313
  line: {
5288
5314
  normal: {
@@ -5389,18 +5415,35 @@ System.register([], (function (exports) {
5389
5415
  blur: 2,
5390
5416
  color: '#ccc'
5391
5417
  }
5418
+ },
5419
+ candlestick: {
5420
+ normal: {
5421
+ lineWidth: 1,
5422
+ zIndex: 18,
5423
+ cursor: 'default'
5424
+ },
5425
+ hover: {
5426
+ //zIndex: 100,
5427
+ cursor: 'pointer'
5428
+ },
5429
+ perWidth: 0.5,
5430
+ // 阴线颜色
5431
+ negativeColor: 'green',
5432
+ // 阳线颜色
5433
+ masculineColor: 'red',
5434
+ lineWidth: 1
5392
5435
  }
5393
5436
  };
5394
5437
 
5395
- /**
5396
- * 轴
5397
- *
5398
- * @class jmAxis
5399
- * @module jmChart
5400
- * @param {jmChart} chart 当前图表
5401
- * @param {string} [type] 轴类型(x/y/radar),默认为x
5402
- * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
5403
- * @param {object} [style] 样式
5438
+ /**
5439
+ * 轴
5440
+ *
5441
+ * @class jmAxis
5442
+ * @module jmChart
5443
+ * @param {jmChart} chart 当前图表
5444
+ * @param {string} [type] 轴类型(x/y/radar),默认为x
5445
+ * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
5446
+ * @param {object} [style] 样式
5404
5447
  */
5405
5448
 
5406
5449
  class jmAxis extends jmArrowLine {
@@ -5447,21 +5490,21 @@ System.register([], (function (exports) {
5447
5490
 
5448
5491
  if (typeof options.minXValue !== 'undefined') this.minValue = options.minXValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
5449
5492
  } else {
5450
- if (typeof options.maxYValue !== 'undefined') this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
5493
+ if (typeof options.maxYValue !== 'undefined' && (options.maxYValue > this.maxValue || typeof this.maxValue === 'undefined')) this.maxValue = options.maxYValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
5451
5494
 
5452
- if (typeof options.minYValue !== 'undefined') this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
5495
+ if (typeof options.minYValue !== 'undefined' && (options.minYValue < this.minValue || typeof this.minValue === 'undefined')) this.minValue = options.minYValue; // 最小值,如果指定了,则轴的最小值为它或更小的值
5453
5496
  }
5454
5497
  }
5455
- /**
5456
- * 轴类型(x/y/radar),默认为x
5457
- *
5458
- * @property type
5459
- * @type string
5498
+ /**
5499
+ * 轴类型(x/y/radar),默认为x
5500
+ *
5501
+ * @property type
5502
+ * @type string
5460
5503
  */
5461
5504
 
5462
5505
 
5463
- /**
5464
- * 关联访问的是chart的数据源
5506
+ /**
5507
+ * 关联访问的是chart的数据源
5465
5508
  */
5466
5509
  get data() {
5467
5510
  return this.graph.data;
@@ -5470,10 +5513,10 @@ System.register([], (function (exports) {
5470
5513
  set data(d) {
5471
5514
  this.graph.data = d;
5472
5515
  }
5473
- /**
5474
- * 计算当前轴的位置
5475
- *
5476
- * @method reset
5516
+ /**
5517
+ * 计算当前轴的位置
5518
+ *
5519
+ * @method reset
5477
5520
  */
5478
5521
 
5479
5522
 
@@ -5531,10 +5574,10 @@ System.register([], (function (exports) {
5531
5574
 
5532
5575
  super.draw();
5533
5576
  }
5534
- /**
5535
- * 生成轴标签
5536
- *
5537
- * @method createLabel
5577
+ /**
5578
+ * 生成轴标签
5579
+ *
5580
+ * @method createLabel
5538
5581
  */
5539
5582
 
5540
5583
 
@@ -5551,11 +5594,11 @@ System.register([], (function (exports) {
5551
5594
  this.createYLabel();
5552
5595
  }
5553
5596
  }
5554
- /**
5555
- * 生成X轴标签
5556
- *
5557
- * @method createXLabel
5558
- * @private
5597
+ /**
5598
+ * 生成X轴标签
5599
+ *
5600
+ * @method createXLabel
5601
+ * @private
5559
5602
  */
5560
5603
 
5561
5604
 
@@ -5646,11 +5689,11 @@ System.register([], (function (exports) {
5646
5689
  }
5647
5690
  }
5648
5691
  }
5649
- /**
5650
- * 生成Y轴标签
5651
- *
5652
- * @method createYLabel
5653
- * @private
5692
+ /**
5693
+ * 生成Y轴标签
5694
+ *
5695
+ * @method createYLabel
5696
+ * @private
5654
5697
  */
5655
5698
 
5656
5699
 
@@ -5663,8 +5706,8 @@ System.register([], (function (exports) {
5663
5706
 
5664
5707
  let count = this.labelCount;
5665
5708
  const mm = max - min;
5666
- /*if(mm <= 10) {
5667
- count = mm;
5709
+ /*if(mm <= 10) {
5710
+ count = mm;
5668
5711
  }*/
5669
5712
  // mm 放大10000倍,这里结果也需要除于10000
5670
5713
 
@@ -5776,10 +5819,10 @@ System.register([], (function (exports) {
5776
5819
  }
5777
5820
  }
5778
5821
  }
5779
- /**
5780
- * 获取当前轴所占宽
5781
- *
5782
- * @method width
5822
+ /**
5823
+ * 获取当前轴所占宽
5824
+ *
5825
+ * @method width
5783
5826
  */
5784
5827
 
5785
5828
 
@@ -5794,10 +5837,10 @@ System.register([], (function (exports) {
5794
5837
  set width(w) {
5795
5838
  this._width = w;
5796
5839
  }
5797
- /**
5798
- * 获取当前轴所占高
5799
- *
5800
- * @method height
5840
+ /**
5841
+ * 获取当前轴所占高
5842
+ *
5843
+ * @method height
5801
5844
  */
5802
5845
 
5803
5846
 
@@ -5807,12 +5850,12 @@ System.register([], (function (exports) {
5807
5850
 
5808
5851
 
5809
5852
  set height(h) {}
5810
- /**
5811
- * 获取或设置当前轴最大值
5812
- *
5813
- * @method max
5814
- * @param {number/date/string} 当前轴的最大值
5815
- * @return 当前轴的最大值
5853
+ /**
5854
+ * 获取或设置当前轴最大值
5855
+ *
5856
+ * @method max
5857
+ * @param {number/date/string} 当前轴的最大值
5858
+ * @return 当前轴的最大值
5816
5859
  */
5817
5860
 
5818
5861
 
@@ -5861,12 +5904,12 @@ System.register([], (function (exports) {
5861
5904
 
5862
5905
  return this._max;
5863
5906
  }
5864
- /**
5865
- * 获取或设置当前轴最小值
5866
- *
5867
- * @method max
5868
- * @param {number/date/string} 当前轴的最小值
5869
- * @return 当前轴的最小值
5907
+ /**
5908
+ * 获取或设置当前轴最小值
5909
+ *
5910
+ * @method max
5911
+ * @param {number/date/string} 当前轴的最小值
5912
+ * @return 当前轴的最小值
5870
5913
  */
5871
5914
 
5872
5915
 
@@ -5913,10 +5956,10 @@ System.register([], (function (exports) {
5913
5956
 
5914
5957
  return this.dataType == 'string' ? 0 : this._min;
5915
5958
  }
5916
- /**
5917
- * 清除一些属性
5918
- *
5919
- * @method clear
5959
+ /**
5960
+ * 清除一些属性
5961
+ *
5962
+ * @method clear
5920
5963
  */
5921
5964
 
5922
5965
 
@@ -5924,11 +5967,11 @@ System.register([], (function (exports) {
5924
5967
  this._min = null;
5925
5968
  this._max = null;
5926
5969
  }
5927
- /**
5928
- * 计算当前轴的单位偏移量
5929
- *
5930
- * @method step
5931
- * @return {number} 单位偏移量
5970
+ /**
5971
+ * 计算当前轴的单位偏移量
5972
+ *
5973
+ * @method step
5974
+ * @return {number} 单位偏移量
5932
5975
  */
5933
5976
 
5934
5977
 
@@ -5977,12 +6020,12 @@ System.register([], (function (exports) {
5977
6020
 
5978
6021
  }
5979
6022
 
5980
- /**
5981
- * 图例的容器
5982
- *
5983
- * @class jmLegend
5984
- * @module jmChart
5985
- * @param {jmChart} chart 当前图表
6023
+ /**
6024
+ * 图例的容器
6025
+ *
6026
+ * @class jmLegend
6027
+ * @module jmChart
6028
+ * @param {jmChart} chart 当前图表
5986
6029
  */
5987
6030
 
5988
6031
  class jmLegend extends jmRect {
@@ -5994,20 +6037,20 @@ System.register([], (function (exports) {
5994
6037
  };
5995
6038
  super(options);
5996
6039
 
5997
- _defineProperty(this, "legendPosition", 'right');
6040
+ _defineProperty(this, "legendPosition", '');
5998
6041
  }
5999
- /**
6000
- * 图例放置位置
6042
+ /**
6043
+ * 图例放置位置
6001
6044
  */
6002
6045
 
6003
6046
 
6004
6047
  }
6005
- /**
6006
- * 添加图例
6007
- *
6008
- * @method append
6009
- * @param {jmSeries} series 当前图序列
6010
- * @param {jmControl} shape 当前图例的图形对象
6048
+ /**
6049
+ * 添加图例
6050
+ *
6051
+ * @method append
6052
+ * @param {jmSeries} series 当前图序列
6053
+ * @param {jmControl} shape 当前图例的图形对象
6011
6054
  */
6012
6055
 
6013
6056
  jmLegend.prototype.append = function (series, shape, options = {}) {
@@ -6047,24 +6090,27 @@ System.register([], (function (exports) {
6047
6090
  panel.height = shape.height; //执行进入事件
6048
6091
  //触动图例后加粗显示图
6049
6092
 
6050
- /*const hover = options.hover || function() {
6051
- //应用图的动态样式
6052
- //Object.assign(series.style, series.style.hover);
6053
- //Object.assign(this.style, this.style.hover || {});
6054
- //series.graph.refresh();
6055
- };
6056
- panel.bind('mouseover', hover);
6057
- //执行离开
6058
- const leave = options.leave || function() {
6059
- //应用图的普通样式
6060
- //Object.assign(series.style, series.style.normal);
6061
- //Object.assign(this.style, this.style.normal || {});
6062
- //jmUtils.apply(this.series.style.normal,this.series.style);
6063
- //series.graph.refresh();
6064
- };
6093
+ /*const hover = options.hover || function() {
6094
+ //应用图的动态样式
6095
+ //Object.assign(series.style, series.style.hover);
6096
+
6097
+ //Object.assign(this.style, this.style.hover || {});
6098
+
6099
+ //series.graph.refresh();
6100
+ };
6101
+ panel.bind('mouseover', hover);
6102
+ //执行离开
6103
+ const leave = options.leave || function() {
6104
+ //应用图的普通样式
6105
+ //Object.assign(series.style, series.style.normal);
6106
+
6107
+ //Object.assign(this.style, this.style.normal || {});
6108
+ //jmUtils.apply(this.series.style.normal,this.series.style);
6109
+ //series.graph.refresh();
6110
+ };
6065
6111
  panel.bind('mouseleave', leave);*/
6066
6112
 
6067
- const legendPosition = this.legendPosition || this.style.legendPosition;
6113
+ const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
6068
6114
 
6069
6115
  if (legendPosition == 'top' || legendPosition == 'bottom') {
6070
6116
  //顶部和底部图例横排,每次右移位一个单位图例
@@ -6081,10 +6127,10 @@ System.register([], (function (exports) {
6081
6127
 
6082
6128
  this.needUpdate = true;
6083
6129
  };
6084
- /**
6085
- * 初始化图例
6086
- *
6087
- * @method init
6130
+ /**
6131
+ * 初始化图例
6132
+ *
6133
+ * @method init
6088
6134
  */
6089
6135
 
6090
6136
 
@@ -6096,10 +6142,10 @@ System.register([], (function (exports) {
6096
6142
  this.style.lineWidth = 0;
6097
6143
  this.children.clear();
6098
6144
  };
6099
- /**
6100
- * 重置图例属性,根据图例内容计算期大小并更新画图区域大小
6101
- *
6102
- * @method reset
6145
+ /**
6146
+ * 重置图例属性,根据图例内容计算期大小并更新画图区域大小
6147
+ *
6148
+ * @method reset
6103
6149
  */
6104
6150
 
6105
6151
 
@@ -6144,11 +6190,11 @@ System.register([], (function (exports) {
6144
6190
  };
6145
6191
 
6146
6192
  var utils = {
6147
- /**
6148
- * 对比二个数组数据是否改变
6149
- * @param {Array} source 被对比的数、组
6150
- * @param {Array} target 对比数组
6151
- * @param {Function} compare 比较函数
6193
+ /**
6194
+ * 对比二个数组数据是否改变
6195
+ * @param {Array} source 被对比的数、组
6196
+ * @param {Array} target 对比数组
6197
+ * @param {Function} compare 比较函数
6152
6198
  */
6153
6199
  arrayIsChange(source, target, compare) {
6154
6200
  if (!source || !target) return true;
@@ -6165,14 +6211,14 @@ System.register([], (function (exports) {
6165
6211
 
6166
6212
  };
6167
6213
 
6168
- /**
6169
- * 图形基类
6170
- *
6171
- * @class jmSeries
6172
- * @module jmChart
6173
- * @param {jmChart} chart 当前图表
6174
- * @param {array} mappings 图形字段映射
6175
- * @param {style} style 样式
6214
+ /**
6215
+ * 图形基类
6216
+ *
6217
+ * @class jmSeries
6218
+ * @module jmChart
6219
+ * @param {jmChart} chart 当前图表
6220
+ * @param {array} mappings 图形字段映射
6221
+ * @param {style} style 样式
6176
6222
  */
6177
6223
  //构造线图
6178
6224
 
@@ -6216,8 +6262,8 @@ System.register([], (function (exports) {
6216
6262
  maxYValue: options.maxYValue
6217
6263
  });
6218
6264
  }
6219
- /**
6220
- * 关联访问的是chart的数据源
6265
+ /**
6266
+ * 关联访问的是chart的数据源
6221
6267
  */
6222
6268
 
6223
6269
 
@@ -6239,11 +6285,11 @@ System.register([], (function (exports) {
6239
6285
  set enableAnimate(v) {
6240
6286
  this.option.enableAnimate = v;
6241
6287
  }
6242
- /**
6243
- * 图例名称
6244
- *
6245
- * @property legendLabel
6246
- * @type string
6288
+ /**
6289
+ * 图例名称
6290
+ *
6291
+ * @property legendLabel
6292
+ * @type string
6247
6293
  */
6248
6294
 
6249
6295
 
@@ -6273,10 +6319,10 @@ System.register([], (function (exports) {
6273
6319
  points: this.dataPoints
6274
6320
  };
6275
6321
  }
6276
- /**
6277
- * 根据X轴坐标,获取它最近的数据描点
6278
- * 离点最近的一个描点
6279
- * @param {number} x X轴坐标
6322
+ /**
6323
+ * 根据X轴坐标,获取它最近的数据描点
6324
+ * 离点最近的一个描点
6325
+ * @param {number} x X轴坐标
6280
6326
  */
6281
6327
 
6282
6328
 
@@ -6304,9 +6350,9 @@ System.register([], (function (exports) {
6304
6350
 
6305
6351
  return null;
6306
6352
  }
6307
- /**
6308
- * 根据X轴值获取数据点
6309
- * @param {number} xValue X轴值
6353
+ /**
6354
+ * 根据X轴值获取数据点
6355
+ * @param {number} xValue X轴值
6310
6356
  */
6311
6357
 
6312
6358
 
@@ -6320,11 +6366,11 @@ System.register([], (function (exports) {
6320
6366
 
6321
6367
  return null;
6322
6368
  }
6323
- /**
6324
- * 重置属性
6325
- * 根据数据源计算轴的属性
6326
- *
6327
- * @method reset
6369
+ /**
6370
+ * 重置属性
6371
+ * 根据数据源计算轴的属性
6372
+ *
6373
+ * @method reset
6328
6374
  */
6329
6375
 
6330
6376
 
@@ -6368,10 +6414,10 @@ System.register([], (function (exports) {
6368
6414
  this.xAxis.min(xv);
6369
6415
  }
6370
6416
  }
6371
- /**
6372
- * 生成序列图描点
6373
- *
6374
- * @method createPoints
6417
+ /**
6418
+ * 生成序列图描点
6419
+ *
6420
+ * @method createPoints
6375
6421
  */
6376
6422
 
6377
6423
 
@@ -6413,7 +6459,8 @@ System.register([], (function (exports) {
6413
6459
  x: p.x,
6414
6460
  // 高度
6415
6461
  height: p.height,
6416
- yValue: yv
6462
+ yValue: yv,
6463
+ field: f
6417
6464
  }; //如果Y值不存在。则此点无效,不画图
6418
6465
 
6419
6466
  if (yv == null || typeof yv == 'undefined') {
@@ -6448,10 +6495,10 @@ System.register([], (function (exports) {
6448
6495
  return this.style.color;
6449
6496
  }
6450
6497
  }
6451
- /**
6452
- * 生成图例
6453
- *
6454
- * @method createLegend
6498
+ /**
6499
+ * 生成图例
6500
+ *
6501
+ * @method createLegend
6455
6502
  */
6456
6503
 
6457
6504
 
@@ -6503,9 +6550,9 @@ System.register([], (function (exports) {
6503
6550
  });
6504
6551
  this.addShape(label);
6505
6552
  }
6506
- /**
6507
- * 在图上加下定制图形
6508
- * @param {jmShape} shape 图形
6553
+ /**
6554
+ * 在图上加下定制图形
6555
+ * @param {jmShape} shape 图形
6509
6556
  */
6510
6557
 
6511
6558
 
@@ -6514,13 +6561,13 @@ System.register([], (function (exports) {
6514
6561
  this.shapes.add(shape);
6515
6562
  return shape;
6516
6563
  }
6517
- /**
6518
- * 获取指定事件的集合
6519
- * 比如mousedown,mouseup等
6520
- *
6521
- * @method getEvent
6522
- * @param {string} name 事件名称
6523
- * @return {list} 事件委托的集合
6564
+ /**
6565
+ * 获取指定事件的集合
6566
+ * 比如mousedown,mouseup等
6567
+ *
6568
+ * @method getEvent
6569
+ * @param {string} name 事件名称
6570
+ * @return {list} 事件委托的集合
6524
6571
  */
6525
6572
 
6526
6573
 
@@ -6544,14 +6591,14 @@ System.register([], (function (exports) {
6544
6591
 
6545
6592
  }
6546
6593
 
6547
- /**
6548
- * 柱图
6549
- *
6550
- * @class jmBarSeries
6551
- * @module jmChart
6552
- * @param {jmChart} chart 当前图表
6553
- * @param {array} mappings 图形字段映射
6554
- * @param {style} style 样式
6594
+ /**
6595
+ * 柱图
6596
+ *
6597
+ * @class jmBarSeries
6598
+ * @module jmChart
6599
+ * @param {jmChart} chart 当前图表
6600
+ * @param {array} mappings 图形字段映射
6601
+ * @param {style} style 样式
6555
6602
  */
6556
6603
  //构造函数
6557
6604
 
@@ -6559,11 +6606,11 @@ System.register([], (function (exports) {
6559
6606
  constructor(options) {
6560
6607
  super(options);
6561
6608
  }
6562
- /**
6563
- * 绘制当前图形
6564
- *
6565
- * @method beginDraw
6566
- * @for jmBarSeries
6609
+ /**
6610
+ * 绘制当前图形
6611
+ *
6612
+ * @method beginDraw
6613
+ * @for jmBarSeries
6567
6614
  */
6568
6615
 
6569
6616
 
@@ -6670,9 +6717,9 @@ System.register([], (function (exports) {
6670
6717
  this.barTotalWidth = maxWidth * this.graph.barSeriesCount;
6671
6718
  }
6672
6719
  }
6673
- /**
6674
- * 在图上加下定制图形
6675
- * @param {jmShape} shape 图形
6720
+ /**
6721
+ * 在图上加下定制图形
6722
+ * @param {jmShape} shape 图形
6676
6723
  */
6677
6724
 
6678
6725
 
@@ -6684,14 +6731,14 @@ System.register([], (function (exports) {
6684
6731
 
6685
6732
  }
6686
6733
 
6687
- /**
6688
- * 柱图
6689
- *
6690
- * @class jmBarSeries
6691
- * @module jmChart
6692
- * @param {jmChart} chart 当前图表
6693
- * @param {array} mappings 图形字段映射
6694
- * @param {style} style 样式
6734
+ /**
6735
+ * 柱图
6736
+ *
6737
+ * @class jmBarSeries
6738
+ * @module jmChart
6739
+ * @param {jmChart} chart 当前图表
6740
+ * @param {array} mappings 图形字段映射
6741
+ * @param {style} style 样式
6695
6742
  */
6696
6743
  //构造函数
6697
6744
 
@@ -6699,11 +6746,11 @@ System.register([], (function (exports) {
6699
6746
  constructor(options) {
6700
6747
  super(options);
6701
6748
  }
6702
- /**
6703
- * 绘制当前图形
6704
- *
6705
- * @method beginDraw
6706
- * @for jmBarSeries
6749
+ /**
6750
+ * 绘制当前图形
6751
+ *
6752
+ * @method beginDraw
6753
+ * @for jmBarSeries
6707
6754
  */
6708
6755
 
6709
6756
 
@@ -6833,14 +6880,14 @@ System.register([], (function (exports) {
6833
6880
 
6834
6881
  }
6835
6882
 
6836
- /**
6837
- * 饼图
6838
- *
6839
- * @class jmPieSeries
6840
- * @module jmChart
6841
- * @param {jmChart} chart 当前图表
6842
- * @param {array} mappings 图形字段映射
6843
- * @param {style} style 样式
6883
+ /**
6884
+ * 饼图
6885
+ *
6886
+ * @class jmPieSeries
6887
+ * @module jmChart
6888
+ * @param {jmChart} chart 当前图表
6889
+ * @param {array} mappings 图形字段映射
6890
+ * @param {style} style 样式
6844
6891
  */
6845
6892
  //构造函数
6846
6893
 
@@ -6924,10 +6971,10 @@ System.register([], (function (exports) {
6924
6971
  set startAngle(v) {
6925
6972
  this.option.startAngle = v;
6926
6973
  }
6927
- /**
6928
- * 生成序列图描点
6929
- *
6930
- * @method createPoints
6974
+ /**
6975
+ * 生成序列图描点
6976
+ *
6977
+ * @method createPoints
6931
6978
  */
6932
6979
 
6933
6980
 
@@ -7017,8 +7064,8 @@ System.register([], (function (exports) {
7017
7064
  maxRadius: p.maxRadius,
7018
7065
  minRadius: p.minRadius
7019
7066
  });
7020
- /**
7021
- * 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
7067
+ /**
7068
+ * 因为jmgraph是按图形形状来计算所占区域和大小的, 这里我们把扇形占区域改为整个图圆。这样计算大小和渐变时才好闭合。
7022
7069
  */
7023
7070
 
7024
7071
  p.shape.getLocation = function () {
@@ -7127,10 +7174,10 @@ System.register([], (function (exports) {
7127
7174
  }
7128
7175
 
7129
7176
  }
7130
- /**
7131
- * 生成图例
7132
- *
7133
- * @method createLegend
7177
+ /**
7178
+ * 生成图例
7179
+ *
7180
+ * @method createLegend
7134
7181
  */
7135
7182
 
7136
7183
  jmPieSeries.prototype.createLegend = function () {
@@ -7172,14 +7219,14 @@ System.register([], (function (exports) {
7172
7219
  }
7173
7220
  };
7174
7221
 
7175
- /**
7176
- * 图形基类
7177
- *
7178
- * @class jmLineSeries
7179
- * @module jmChart
7180
- * @param {jmChart} chart 当前图表
7181
- * @param {array} mappings 图形字段映射
7182
- * @param {style} style 样式
7222
+ /**
7223
+ * 图形基类
7224
+ *
7225
+ * @class jmLineSeries
7226
+ * @module jmChart
7227
+ * @param {jmChart} chart 当前图表
7228
+ * @param {array} mappings 图形字段映射
7229
+ * @param {style} style 样式
7183
7230
  */
7184
7231
  //构造函数
7185
7232
 
@@ -7188,11 +7235,11 @@ System.register([], (function (exports) {
7188
7235
  options.style = options.style || options.graph.style.line;
7189
7236
  super(options); //this.on('beginDraw', this[PreDrawKey]);
7190
7237
  }
7191
- /**
7192
- * 绘制图形前 初始化线条
7193
- *
7194
- * @method preDraw
7195
- * @for jmLineSeries
7238
+ /**
7239
+ * 绘制图形前 初始化线条
7240
+ *
7241
+ * @method preDraw
7242
+ * @for jmLineSeries
7196
7243
  */
7197
7244
 
7198
7245
 
@@ -7327,10 +7374,10 @@ System.register([], (function (exports) {
7327
7374
 
7328
7375
  return shapePoints;
7329
7376
  }
7330
- /**
7331
- * 生成图例
7332
- *
7333
- * @method createLegend
7377
+ /**
7378
+ * 生成图例
7379
+ *
7380
+ * @method createLegend
7334
7381
  */
7335
7382
 
7336
7383
 
@@ -7419,14 +7466,14 @@ System.register([], (function (exports) {
7419
7466
 
7420
7467
  }
7421
7468
 
7422
- /**
7423
- * 二条线组成的区域图表
7424
- *
7425
- * @class jmStackLineSeries
7426
- * @module jmChart
7427
- * @param {jmChart} chart 当前图表
7428
- * @param {array} mappings 图形字段映射
7429
- * @param {style} style 样式
7469
+ /**
7470
+ * 二条线组成的区域图表
7471
+ *
7472
+ * @class jmStackLineSeries
7473
+ * @module jmChart
7474
+ * @param {jmChart} chart 当前图表
7475
+ * @param {array} mappings 图形字段映射
7476
+ * @param {style} style 样式
7430
7477
  */
7431
7478
  //构造函数
7432
7479
 
@@ -7435,11 +7482,11 @@ System.register([], (function (exports) {
7435
7482
  options.style = options.style || options.graph.style.stackLine;
7436
7483
  super(options);
7437
7484
  }
7438
- /**
7439
- * 绘制图形前 初始化线条
7440
- *
7441
- * @method preDraw
7442
- * @for jmLineSeries
7485
+ /**
7486
+ * 绘制图形前 初始化线条
7487
+ *
7488
+ * @method preDraw
7489
+ * @for jmLineSeries
7443
7490
  */
7444
7491
 
7445
7492
 
@@ -7519,10 +7566,10 @@ System.register([], (function (exports) {
7519
7566
  areaEnd.m = false;
7520
7567
  this.createArea(areaPoints, false);
7521
7568
  }
7522
- /**
7523
- * 生成图例
7524
- *
7525
- * @method createLegend
7569
+ /**
7570
+ * 生成图例
7571
+ *
7572
+ * @method createLegend
7526
7573
  */
7527
7574
 
7528
7575
 
@@ -7570,15 +7617,114 @@ System.register([], (function (exports) {
7570
7617
 
7571
7618
  }
7572
7619
 
7573
- /**
7574
- * 轴
7575
- *
7576
- * @class jmAxis
7577
- * @module jmChart
7578
- * @param {jmChart} chart 当前图表
7579
- * @param {string} [type] 轴类型(x/y/radar),默认为x
7580
- * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
7581
- * @param {object} [style] 样式
7620
+ /**
7621
+ * K线图
7622
+ *
7623
+ * @class jmCandlestickSeries
7624
+ * @module jmChart
7625
+ * @param {jmChart} chart 当前图表
7626
+ * @param {array} mappings 图形字段映射
7627
+ * @param {style} style 样式
7628
+ */
7629
+ //构造函数
7630
+
7631
+ class jmCandlestickSeries extends jmSeries {
7632
+ constructor(options) {
7633
+ options.style = options.style || options.graph.style.line;
7634
+ super(options); //this.on('beginDraw', this[PreDrawKey]);
7635
+ }
7636
+ /**
7637
+ * 绘制图形前 初始化线条
7638
+ *
7639
+ * @method preDraw
7640
+ * @for jmLineSeries
7641
+ */
7642
+
7643
+
7644
+ init() {
7645
+ //生成描点位
7646
+ const {
7647
+ points
7648
+ } = this.initDataPoint(); //去除多余的线条
7649
+ //当数据源线条数比现有的少时,删除多余的线条
7650
+
7651
+ const len = points.length;
7652
+ this.initWidth(len);
7653
+ const w = this.barWidth / 2; //实心处宽度的一半
7654
+
7655
+ for (let i = 0; i < len; i++) {
7656
+ const p = points[i]; //如果当前点无效,则跳致下一点
7657
+
7658
+ if (typeof p.y === 'undefined' || p.y === null) {
7659
+ //prePoint = null;
7660
+ continue;
7661
+ }
7662
+
7663
+ const sp = this.addShape(this.graph.createPath([], p.style));
7664
+ const bl = {
7665
+ x: p.x - w,
7666
+ y: p.points[0].y
7667
+ };
7668
+ const br = {
7669
+ x: p.x + w,
7670
+ y: p.points[0].y
7671
+ };
7672
+ const tl = {
7673
+ x: p.x - w,
7674
+ y: p.points[1].y
7675
+ };
7676
+ const tr = {
7677
+ x: p.x + w,
7678
+ y: p.points[1].y
7679
+ }; // 默认认为是阳线
7680
+
7681
+ let tm = p.points[1];
7682
+ let bm = p.points[0];
7683
+ p.style.stroke = p.style.fill = p.style.masculineColor || 'red'; // 开盘大于收盘,则阴线
7684
+
7685
+ if (p.points[0].yValue > p.points[1].yValue) {
7686
+ p.style.stroke = p.style.fill = p.style.negativeColor || 'green';
7687
+ bl.y = br.y = p.points[1].y;
7688
+ tl.y = tr.y = p.points[0].y;
7689
+ tm = p.points[0];
7690
+ bm = p.points[1];
7691
+ }
7692
+
7693
+ sp.points.push(p.points[2], tm, tl, bl, bm, p.points[3], bm, br, tr, tm, p.points[2]); // 生成关健值标注
7694
+
7695
+ this.emit('onPointCreated', p);
7696
+ }
7697
+ } // 计算实心体宽度
7698
+
7699
+
7700
+ initWidth(count) {
7701
+ //计算每个柱子占宽
7702
+ //每项柱子占宽除以柱子个数,默认最大宽度为30
7703
+ const maxWidth = this.xAxis.width / count;
7704
+
7705
+ if (this.style.barWidth > 0) {
7706
+ this.barWidth = Number(this.style.barWidth);
7707
+ } else {
7708
+ this.barWidth = maxWidth * (this.style.perWidth || 0.4);
7709
+ }
7710
+
7711
+ if (this.barWidth > maxWidth) {
7712
+ this.barWidth = maxWidth;
7713
+ this.barTotalWidth = maxWidth * count;
7714
+ }
7715
+ }
7716
+
7717
+ }
7718
+
7719
+ /**
7720
+ * 轴
7721
+ *
7722
+ * @class jmAxis
7723
+ * @module jmChart
7724
+ * @param {jmChart} chart 当前图表
7725
+ * @param {string} [type] 轴类型(x/y/radar),默认为x
7726
+ * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
7727
+ * @param {object} [style] 样式
7582
7728
  */
7583
7729
 
7584
7730
  class jmMarkLine extends jmLine {
@@ -7587,8 +7733,8 @@ System.register([], (function (exports) {
7587
7733
  this.visible = false;
7588
7734
  this.markLineType = options.type || 'x'; // 为横轴x或纵轴y
7589
7735
 
7590
- /**
7591
- * 当前图形下的所有子图
7736
+ /**
7737
+ * 当前图形下的所有子图
7592
7738
  */
7593
7739
 
7594
7740
  this.shapes = new jmList();
@@ -7651,8 +7797,8 @@ System.register([], (function (exports) {
7651
7797
  serie.lastMarkPoint = point; // 记下最后一次改变的点
7652
7798
  // 同时改变下X轴标线的位置,它的Y坐标跟随最后一个命中的线点
7653
7799
 
7654
- if (graph && graph.xMarkLine) {
7655
- graph.xMarkLine.start.y = graph.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
7800
+ if (graph && graph.markLine && graph.markLine.xMarkLine) {
7801
+ graph.markLine.xMarkLine.start.y = graph.markLine.xMarkLine.end.y = isTocuhGraph ? point.y + graph.chartArea.position.y : point.y;
7656
7802
  }
7657
7803
  }
7658
7804
  } catch (e) {
@@ -7667,9 +7813,9 @@ System.register([], (function (exports) {
7667
7813
  }, 10);
7668
7814
  }
7669
7815
  }
7670
- /**
7671
- * 移动标线
7672
- * @param { object } args 移动事件参数
7816
+ /**
7817
+ * 移动标线
7818
+ * @param { object } args 移动事件参数
7673
7819
  */
7674
7820
 
7675
7821
 
@@ -7733,8 +7879,8 @@ System.register([], (function (exports) {
7733
7879
  this.needUpdate = true;
7734
7880
  }
7735
7881
  }
7736
- /**
7737
- * 中止
7882
+ /**
7883
+ * 中止
7738
7884
  */
7739
7885
 
7740
7886
 
@@ -7745,13 +7891,169 @@ System.register([], (function (exports) {
7745
7891
 
7746
7892
  }
7747
7893
 
7748
- /**
7749
- * jm图表组件
7750
- * option参数:graph=jmgraph
7751
- *
7752
- * @class jmChart
7753
- * @module jmChart
7754
- * @param {element} container 图表容器
7894
+ /**
7895
+ * 轴
7896
+ *
7897
+ * @class jmMarkLineManager
7898
+ * @module jmChart
7899
+ * @param {jmChart} chart 当前图表
7900
+ * @param {string} [type] 轴类型(x/y/radar),默认为x
7901
+ * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
7902
+ * @param {object} [style] 样式
7903
+ */
7904
+
7905
+ class jmMarkLineManager {
7906
+ constructor(chart) {
7907
+ this.chart = chart;
7908
+ this.init(chart);
7909
+ } // 初始化
7910
+
7911
+
7912
+ init(chart) {
7913
+ const graph = chart.touchGraph || chart;
7914
+ graph.on('beginDraw', () => {
7915
+ // 重置标线,会处理小圆圈问题
7916
+ this.xMarkLine && this.xMarkLine.init();
7917
+ this.yMarkLine && this.yMarkLine.init();
7918
+ });
7919
+
7920
+ if (chart.style.markLine) {
7921
+ // 生成标线,可以跟随鼠标或手指滑动
7922
+ if (chart.style.markLine && chart.style.markLine.x) {
7923
+ this.xMarkLine = graph.createShape(jmMarkLine, {
7924
+ type: 'x',
7925
+ style: chart.style.markLine
7926
+ });
7927
+ const area = graph.chartArea || graph;
7928
+ area.children.add(this.xMarkLine);
7929
+ }
7930
+
7931
+ if (chart.style.markLine && chart.style.markLine.y) {
7932
+ this.yMarkLine = graph.createShape(jmMarkLine, {
7933
+ type: 'y',
7934
+ style: chart.style.markLine
7935
+ });
7936
+ const area = graph.chartArea || graph;
7937
+ area.children.add(this.yMarkLine);
7938
+ }
7939
+
7940
+ let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7941
+
7942
+ let longtapHandler = 0;
7943
+ let touchStartPos = {
7944
+ x: 0,
7945
+ y: 0
7946
+ };
7947
+ graph.on('mousedown touchstart', args => {
7948
+ // 如果长按才启用
7949
+ if (chart.style.markLine.longtap) {
7950
+ longtap = 1;
7951
+ longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
7952
+ let tapStartTime = Date.now();
7953
+
7954
+ const reqFun = () => {
7955
+ const elapsed = Date.now() - tapStartTime;
7956
+
7957
+ if (longtap === 1 || longtap === 2) {
7958
+ // 如果还未过一定时间,则继续等待
7959
+ if (elapsed < 500) {
7960
+ longtapHandler = graph.utils.requestAnimationFrame(reqFun);
7961
+ return;
7962
+ }
7963
+
7964
+ longtap = 2;
7965
+ this.startMove(args);
7966
+ chart.emit('marklinelongtapstart', args);
7967
+ }
7968
+ }; // 如果一定时间后还没有取消,则表示长按了
7969
+
7970
+
7971
+ longtapHandler = graph.utils.requestAnimationFrame(reqFun); //args.event.stopPropagation();
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 图表容器
7755
8057
  */
7756
8058
 
7757
8059
  class jmChart extends jmGraph {
@@ -7780,13 +8082,13 @@ System.register([], (function (exports) {
7780
8082
 
7781
8083
  this.createTouchGraph(this.container, options);
7782
8084
  }
7783
- /**
7784
- * 绑定的数据源
8085
+ /**
8086
+ * 绑定的数据源
7785
8087
  */
7786
8088
 
7787
8089
 
7788
- /**
7789
- * 是否启用动画
8090
+ /**
8091
+ * 是否启用动画
7790
8092
  */
7791
8093
  get enableAnimate() {
7792
8094
  if (typeof this.option.enableAnimate !== 'undefined') return !!this.option.enableAnimate;else {
@@ -7797,8 +8099,8 @@ System.register([], (function (exports) {
7797
8099
  set enableAnimate(v) {
7798
8100
  this.option.enableAnimate = v;
7799
8101
  }
7800
- /**
7801
- * Y轴的基线 默认是0
8102
+ /**
8103
+ * Y轴的基线 默认是0
7802
8104
  */
7803
8105
 
7804
8106
 
@@ -7812,11 +8114,11 @@ System.register([], (function (exports) {
7812
8114
 
7813
8115
 
7814
8116
  init(options) {
7815
- /**
7816
- * 绘图区域
7817
- *
7818
- * @property chartArea
7819
- * @type jmControl
8117
+ /**
8118
+ * 绘图区域
8119
+ *
8120
+ * @property chartArea
8121
+ * @type jmControl
7820
8122
  */
7821
8123
  if (!this.chartArea) {
7822
8124
  this.chartArea = this.createShape('rect', {
@@ -7828,11 +8130,11 @@ System.register([], (function (exports) {
7828
8130
  });
7829
8131
  this.children.add(this.chartArea);
7830
8132
  }
7831
- /**
7832
- * 图例
7833
- *
7834
- * @property legend
7835
- * @type jmLegend
8133
+ /**
8134
+ * 图例
8135
+ *
8136
+ * @property legend
8137
+ * @type jmLegend
7836
8138
  */
7837
8139
 
7838
8140
 
@@ -7844,11 +8146,11 @@ System.register([], (function (exports) {
7844
8146
  if (options.legendVisible === false) {
7845
8147
  this.legend.visible = false;
7846
8148
  }
7847
- /**
7848
- * 图表提示控件
7849
- *
7850
- * @property tooltip
7851
- * @type jmTooltip
8149
+ /**
8150
+ * 图表提示控件
8151
+ *
8152
+ * @property tooltip
8153
+ * @type jmTooltip
7852
8154
  */
7853
8155
  //this.tooltip = this.graph.createShape('tooltip',{style:this.style.tooltip});
7854
8156
  //this.chartArea.children.add(this.tooltip);
@@ -7866,84 +8168,36 @@ System.register([], (function (exports) {
7866
8168
  container && (container.style.position = 'relative');
7867
8169
  options = this.utils.clone(options, {
7868
8170
  autoRefresh: true
7869
- }, true);
7870
- let graph = this.touchGraph = this; // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
8171
+ }, true); // 生成图层, 当图刷新慢时,需要用一个操作图层来进行滑动等操作重绘
7871
8172
  // isWXMiniApp 非微信小程序下才能创建
7872
8173
 
7873
- if (!graph.isWXMiniApp && container && options.touchGraph) {
8174
+ if (!this.isWXMiniApp && container && options.touchGraph) {
7874
8175
  let cn = document.createElement('canvas');
7875
8176
  cn.width = container.offsetWidth || container.clientWidth;
7876
8177
  cn.height = container.offsetHeight || container.clientHeight;
7877
8178
  cn.style.position = 'absolute';
7878
8179
  cn.style.top = 0;
7879
8180
  cn.style.left = 0;
7880
- this.touchGraph = graph = new jmGraph(cn, options);
8181
+ this.touchGraph = new jmGraph(cn, options);
7881
8182
  container.appendChild(cn);
7882
8183
  this.touchGraph.chartGraph = this;
7883
8184
  this.on('propertyChange', (name, args) => {
7884
8185
  if (['width', 'height'].includes(name)) {
7885
8186
  this.touchGraph[name] = args.newValue / this.devicePixelRatio;
7886
8187
  }
7887
- });
7888
- }
7889
-
7890
- if (this.style.markLine) {
7891
- graph.on('beginDraw', () => {
7892
- // 重置标线,会处理小圆圈问题
7893
- this.xMarkLine && this.xMarkLine.init();
7894
- this.yMarkLine && this.yMarkLine.init();
7895
- }); // 生成标线,可以跟随鼠标或手指滑动
7896
-
7897
- if (this.style.markLine && this.style.markLine.x) {
7898
- this.xMarkLine = graph.createShape(jmMarkLine, {
7899
- type: 'x',
7900
- style: this.style.markLine
7901
- });
7902
- const area = graph.chartArea || graph;
7903
- area.children.add(this.xMarkLine);
7904
- }
7905
-
7906
- if (this.style.markLine && this.style.markLine.y) {
7907
- this.yMarkLine = graph.createShape(jmMarkLine, {
7908
- type: 'y',
7909
- style: this.style.markLine
7910
- });
7911
- const area = graph.chartArea || graph;
7912
- area.children.add(this.yMarkLine);
7913
- }
7914
-
7915
- graph.on('mousedown touchstart', args => {
7916
- if (this.xMarkLine) {
7917
- this.xMarkLine.visible = true;
7918
- this.xMarkLine.move(args);
7919
- }
8188
+ }); // 把上层canvse事件传递给绘图层对象
7920
8189
 
7921
- if (this.yMarkLine) {
7922
- this.yMarkLine.visible = true;
7923
- this.yMarkLine.move(args);
7924
- }
7925
- }); // 移动标线
7926
-
7927
- graph.on('mousemove touchmove', args => {
7928
- if (this.xMarkLine && this.xMarkLine.visible) {
7929
- this.xMarkLine.move(args);
7930
- }
8190
+ this.touchGraph.on('mousedown touchstart mousemove touchmove mouseup touchend touchcancel touchleave', args => {
8191
+ const eventName = args.event.eventName || args.event.type;
7931
8192
 
7932
- if (this.yMarkLine && this.yMarkLine.visible) {
7933
- this.yMarkLine.move(args);
8193
+ if (eventName) {
8194
+ this.emit(eventName, args);
7934
8195
  }
7935
- }); // 取消移动
8196
+ });
8197
+ } // 初始化标线
7936
8198
 
7937
- graph.on('mouseup touchend touchcancel touchleave', args => {
7938
- if (this.xMarkLine && this.xMarkLine.visible) {
7939
- this.xMarkLine.cancel(args);
7940
- }
7941
8199
 
7942
- if (this.yMarkLine && this.yMarkLine.visible) {
7943
- this.yMarkLine.cancel(args);
7944
- }
7945
- });
7946
- }
8200
+ this.markLine = new jmMarkLineManager(this);
7947
8201
  } // 重置整个图表
7948
8202
 
7949
8203
 
@@ -7976,11 +8230,11 @@ System.register([], (function (exports) {
7976
8230
  delete this.yAxises;
7977
8231
  }
7978
8232
  }
7979
- /**
7980
- * 获取颜色
7981
- *
7982
- * @method getColor
7983
- * @param {int} index 颜色索引
8233
+ /**
8234
+ * 获取颜色
8235
+ *
8236
+ * @method getColor
8237
+ * @param {int} index 颜色索引
7984
8238
  */
7985
8239
 
7986
8240
 
@@ -7992,11 +8246,11 @@ System.register([], (function (exports) {
7992
8246
 
7993
8247
  return this.style.chartColors[index];
7994
8248
  }
7995
- /**
7996
- * 绘制当前图表
7997
- * 先绘制轴等基础信息
7998
- *
7999
- * @method beginDraw
8249
+ /**
8250
+ * 绘制当前图表
8251
+ * 先绘制轴等基础信息
8252
+ *
8253
+ * @method beginDraw
8000
8254
  */
8001
8255
 
8002
8256
 
@@ -8061,10 +8315,10 @@ System.register([], (function (exports) {
8061
8315
  serie.init && serie.init();
8062
8316
  }); //console.log('beginDraw4', Date.now() - startTime);
8063
8317
  }
8064
- /**
8065
- * 重新定位区域的位置
8066
- *
8067
- * @method resetAreaPosition
8318
+ /**
8319
+ * 重新定位区域的位置
8320
+ *
8321
+ * @method resetAreaPosition
8068
8322
  */
8069
8323
 
8070
8324
 
@@ -8076,15 +8330,15 @@ System.register([], (function (exports) {
8076
8330
  this.chartArea.width = w;
8077
8331
  this.chartArea.height = h;
8078
8332
  }
8079
- /**
8080
- * 创建轴
8081
- *
8082
- * @method createAxis
8083
- * @for jmChart
8084
- * @param {string} [type] 轴类型(x/y/radar),默认为x
8085
- * @param {string} [dataType] 当前轴的数据类型(number/date/string),默认为 number
8086
- * @param {object} [style] 样式
8087
- * @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} 轴
8088
8342
  */
8089
8343
 
8090
8344
 
@@ -8096,12 +8350,12 @@ System.register([], (function (exports) {
8096
8350
  this.children.add(axis);
8097
8351
  return axis;
8098
8352
  }
8099
- /**
8100
- * 生成X轴
8101
- *
8102
- * @method createXAxis
8103
- * @param {string} x轴的数据类型(string/number/date)
8104
- * @param {bool} 是否从0开始
8353
+ /**
8354
+ * 生成X轴
8355
+ *
8356
+ * @method createXAxis
8357
+ * @param {string} x轴的数据类型(string/number/date)
8358
+ * @param {bool} 是否从0开始
8105
8359
  */
8106
8360
 
8107
8361
 
@@ -8128,13 +8382,13 @@ System.register([], (function (exports) {
8128
8382
 
8129
8383
  return this.xAxis;
8130
8384
  }
8131
- /**
8132
- * 生成Y轴
8133
- *
8134
- * @method createYAxis
8135
- * @param {int} Y轴索引,可以创建多个Y轴
8136
- * @param {string} y轴的数据类型(string/number/date)
8137
- * @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开始
8138
8392
  */
8139
8393
 
8140
8394
 
@@ -8163,14 +8417,14 @@ System.register([], (function (exports) {
8163
8417
  var yaxis = this.yAxises[options.index] || (this.yAxises[options.index] = this.createAxis(options));
8164
8418
  return yaxis;
8165
8419
  }
8166
- /**
8167
- * 创建图形
8168
- *
8169
- * @method createSeries
8170
- * @for jmChart
8171
- * @param {string} [type] 图类型,(line/bar/pie/radar)
8172
- * @param {object} [options] 生成图表选项 {xField, yField, index}
8173
- * @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} 图形
8174
8428
  */
8175
8429
 
8176
8430
 
@@ -8181,7 +8435,8 @@ System.register([], (function (exports) {
8181
8435
  'bar': jmBarSeries,
8182
8436
  'stackBar': jmStackBarSeries,
8183
8437
  'pie': jmPieSeries,
8184
- 'stackLine': jmStackLineSeries
8438
+ 'stackLine': jmStackLineSeries,
8439
+ 'candlestick': jmCandlestickSeries
8185
8440
  };
8186
8441
  } //默认样式为类型对应的样式
8187
8442
 
@@ -8200,7 +8455,7 @@ System.register([], (function (exports) {
8200
8455
  return serie;
8201
8456
  }
8202
8457
 
8203
- } exports({ 'default': jmChart, jmChart: jmChart });
8458
+ } exports({ default: jmChart, jmChart: jmChart });
8204
8459
 
8205
8460
  var vchart = exports('vChart', {
8206
8461
  props: {
@@ -8324,6 +8579,6 @@ System.register([], (function (exports) {
8324
8579
  template: `<div ref="jmChartContainer" :style="{width: width, height: height}"></div>`
8325
8580
  });
8326
8581
 
8327
- })
8582
+ }
8328
8583
  };
8329
- }));
8584
+ });