jmchart 1.2.0 → 1.2.2

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.
@@ -1668,9 +1668,6 @@ System.register([], function (exports) {
1668
1668
  style = style || jmUtils.clone(this.style, true);
1669
1669
  if(!style) return;
1670
1670
 
1671
- // 当前根据屏幕放大倍数,如果有倍数,则需要对线宽等同比放大
1672
- let scale = this.graph.devicePixelRatio;
1673
-
1674
1671
  /**
1675
1672
  * 样式设定
1676
1673
  *
@@ -1720,7 +1717,7 @@ System.register([], function (exports) {
1720
1717
  }
1721
1718
 
1722
1719
  // 按比例需要放大的样式
1723
- if(scale && style) {
1720
+ /*if(scale && style) {
1724
1721
  switch(mpname) {
1725
1722
  case 'lineWidth': {
1726
1723
  style *= scale;
@@ -1737,7 +1734,7 @@ System.register([], function (exports) {
1737
1734
  break;
1738
1735
  }
1739
1736
  }
1740
- }
1737
+ } */
1741
1738
  this.context[mpname] = style;
1742
1739
  }
1743
1740
  else {
@@ -1844,9 +1841,6 @@ System.register([], function (exports) {
1844
1841
  if(typeof this.canvas.width === 'function') {
1845
1842
  rect.right = this.canvas.width();
1846
1843
  }
1847
- else if(this.canvas.width) {
1848
- rect.right = this.canvas.width;
1849
- }
1850
1844
  else if(this.width) {
1851
1845
  rect.right = this.width;
1852
1846
  }
@@ -1854,9 +1848,6 @@ System.register([], function (exports) {
1854
1848
  if(typeof this.canvas.height === 'function') {
1855
1849
  rect.bottom = this.canvas.height();
1856
1850
  }
1857
- else if(this.canvas.height) {
1858
- rect.bottom = this.canvas.height;
1859
- }
1860
1851
  else if(this.height) {
1861
1852
  rect.bottom = this.height;
1862
1853
  }
@@ -1919,10 +1910,10 @@ System.register([], function (exports) {
1919
1910
  local.height = this.height;
1920
1911
 
1921
1912
  let margin = jmUtils.clone(this.style.margin, {});
1922
- margin.left = (margin.left || 0) * this.graph.devicePixelRatio;
1923
- margin.top = (margin.top || 0) * this.graph.devicePixelRatio;
1924
- margin.right = (margin.right || 0) * this.graph.devicePixelRatio;
1925
- margin.bottom = (margin.bottom || 0) * this.graph.devicePixelRatio;
1913
+ margin.left = (margin.left || 0);
1914
+ margin.top = (margin.top || 0);
1915
+ margin.right = (margin.right || 0);
1916
+ margin.bottom = (margin.bottom || 0);
1926
1917
 
1927
1918
  //如果没有指定位置,但指定了margin。则位置取margin偏移量
1928
1919
  if(local.position) {
@@ -2351,8 +2342,8 @@ System.register([], function (exports) {
2351
2342
  //获取dom位置
2352
2343
  let position = this.getPosition();
2353
2344
  // 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
2354
- const right = position.left + (this.canvas.clientWidth || this.canvas.offsetWidth || this.canvas.width);
2355
- const bottom = position.top + (this.canvas.clientHeight || this.canvas.offsetHeight || this.canvas.height);
2345
+ const right = position.left + this.width;
2346
+ const bottom = position.top + this.height;
2356
2347
  if(p.pageX > right || p.pageX < position.left) {
2357
2348
  return false;
2358
2349
  }
@@ -2441,14 +2432,7 @@ System.register([], function (exports) {
2441
2432
 
2442
2433
  const srcElement = args.srcElement || args.target;
2443
2434
 
2444
- const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
2445
-
2446
- // 如果有指定scale高清处理,需要对坐标处理
2447
- // 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
2448
- if(graph.devicePixelRatio > 0) {
2449
- position.x = position.offsetX = position.x * graph.devicePixelRatio;
2450
- position.y = position.offsetY = position.y * graph.devicePixelRatio;
2451
- }
2435
+ const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
2452
2436
 
2453
2437
  args = {
2454
2438
  position: position,
@@ -4724,11 +4708,19 @@ System.register([], function (exports) {
4724
4708
  this.on('endDraw', function() {
4725
4709
  this.context.translate(-0.5, -0.5);
4726
4710
  });
4727
-
4711
+
4712
+ // devicePixelRatio初始化
4713
+ let dpr = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
4714
+ if(this.isWXMiniApp) {
4715
+ dpr = wx.getSystemInfoSync().pixelRatio || 1;
4716
+ }
4717
+ this.devicePixelRatio = dpr;
4718
+ // 为了解决锯齿问题,先放大canvas再缩放
4719
+ this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
4720
+
4728
4721
  if(this.option.width > 0) this.width = this.option.width;
4729
4722
  if(this.option.height > 0) this.height = this.option.height;
4730
-
4731
- this.resize();
4723
+ this.resize();
4732
4724
 
4733
4725
  //绑定事件
4734
4726
  this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
@@ -4743,25 +4735,19 @@ System.register([], function (exports) {
4743
4735
 
4744
4736
  // 重置canvas大小,并判断高清屏,画图先放大二倍
4745
4737
  resize(w, h) {
4738
+ if(!this.canvas) return;
4746
4739
 
4747
- let scale = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
4748
- if(this.isWXMiniApp) {
4749
- scale = wx.getSystemInfoSync().pixelRatio || 1;
4750
- }
4751
- else if (scale > 1) {
4752
- this.__normalSize = this.__normalSize || { width: 0, height: 0};
4753
- w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
4740
+ this.__normalSize = this.__normalSize || { width: 0, height: 0};
4741
+ w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
4754
4742
 
4755
- if(w) this.__normalSize.width = w;
4756
- if(h) this.__normalSize.height = h;
4757
-
4758
- this.canvas.style && (this.canvas.style.width = w + "px");
4759
- this.canvas.style && (this.canvas.style.height = h + "px");
4760
- this.canvas.height = h * scale;
4761
- this.canvas.width = w *scale;
4762
- this.context.scale(scale, scale);
4763
- this.devicePixelRatio = scale;
4764
- }
4743
+ if(w) this.__normalSize.width = w;
4744
+ if(h) this.__normalSize.height = h;
4745
+
4746
+ this.css('width', w + "px");
4747
+ this.css('height', h + "px");
4748
+ this.canvas.height = h * this.dprScaleSize;
4749
+ this.canvas.width = w * this.dprScaleSize;
4750
+ this.context.scale(this.dprScaleSize, this.dprScaleSize);
4765
4751
  }
4766
4752
 
4767
4753
  /**
@@ -4769,10 +4755,10 @@ System.register([], function (exports) {
4769
4755
  * @param {x, y} point 内部坐标
4770
4756
  */
4771
4757
  pointToPixes(point) {
4772
- if(this.devicePixelRatio && this.devicePixelRatio !== 1) {
4758
+ if(this.dprScaleSize && this.dprScaleSize !== 1) {
4773
4759
  point = Object.assign({}, point, {
4774
- x: point.x / this.devicePixelRatio,
4775
- y: point.y / this.devicePixelRatio
4760
+ x: point.x / this.dprScaleSize,
4761
+ y: point.y / this.dprScaleSize
4776
4762
  });
4777
4763
  }
4778
4764
  return point;
@@ -4784,13 +4770,13 @@ System.register([], function (exports) {
4784
4770
  * @type {number}
4785
4771
  */
4786
4772
  get width() {
4773
+ if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
4787
4774
  if(this.canvas) return this.canvas.width;
4788
4775
  return 0;
4789
4776
  }
4790
4777
  set width(v) {
4791
4778
  this.needUpdate = true;
4792
4779
  if(this.canvas) {
4793
- this.canvas.width = v;
4794
4780
  this.resize(v);
4795
4781
  }
4796
4782
  return v;
@@ -4802,13 +4788,13 @@ System.register([], function (exports) {
4802
4788
  * @type {number}
4803
4789
  */
4804
4790
  get height() {
4791
+ if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
4805
4792
  if(this.canvas) return this.canvas.height;
4806
4793
  return 0;
4807
4794
  }
4808
4795
  set height(v) {
4809
4796
  this.needUpdate = true;
4810
4797
  if(this.canvas) {
4811
- this.canvas.height = v;
4812
4798
  this.resize(0, v);
4813
4799
  }
4814
4800
  return v;
@@ -4832,8 +4818,8 @@ System.register([], function (exports) {
4832
4818
  */
4833
4819
  getPosition() {
4834
4820
  let p = jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
4835
- p.width = this.canvas.width;
4836
- p.height = this.canvas.height;
4821
+ p.width = this.width;
4822
+ p.height = this.height;
4837
4823
  p.right = p.left + p.width;
4838
4824
  p.bottom = p.top + p.height;
4839
4825
  return p;
@@ -4967,23 +4953,13 @@ System.register([], function (exports) {
4967
4953
  * @param {number} [h] 清除画布的高度
4968
4954
  */
4969
4955
  clear(w, h) {
4970
- //this.canvas.width = this.canvas.width;
4971
- if(w && h) {
4972
- //this.zoomActual();//恢复比例缩放
4973
- this.canvas.width = w;
4974
- this.canvas.height = h;
4975
- //保留原有缩放比例
4976
- if(this.scaleSize) {
4977
- if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
4978
- }
4979
- }
4980
- else {
4981
- w = this.canvas.width;
4982
- h = this.canvas.height;
4983
- if(this.scaleSize) {
4956
+ if(!w || !h) {
4957
+ w = this.width;
4958
+ h = this.height;
4959
+ /*if(this.scaleSize) {
4984
4960
  w = w / this.scaleSize.x;
4985
4961
  h = h / this.scaleSize.y;
4986
- }
4962
+ }*/
4987
4963
  }
4988
4964
  //如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
4989
4965
  if(this.style && this.style.fill) {
@@ -5128,6 +5104,9 @@ System.register([], function (exports) {
5128
5104
  return;// 已销毁
5129
5105
  }
5130
5106
  if(self.needUpdate) self.redraw();
5107
+ // 触发刷新事件
5108
+ self.emit('update');
5109
+
5131
5110
  self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5132
5111
  self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5133
5112
  if(callback) callback();
@@ -5730,7 +5709,7 @@ System.register([], function (exports) {
5730
5709
  //字符串轴。则显示每个标签
5731
5710
 
5732
5711
  const format = this.option.format || this.format;
5733
- const top = (this.style.xLabel.margin.top || 0) * this.graph.devicePixelRatio;
5712
+ const top = this.style.xLabel.margin.top || 0;
5734
5713
 
5735
5714
  for (let i = 0; i < this.data.length; i++) {
5736
5715
  const d = this.data[i];
@@ -5826,8 +5805,8 @@ System.register([], function (exports) {
5826
5805
  const mm = max - min;
5827
5806
  let pervalue = mm / count || 1;
5828
5807
  const format = this.option.format || this.format;
5829
- const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
5830
- const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
5808
+ const marginLeft = this.style.yLabel.margin.left || 0;
5809
+ const marginRight = this.style.yLabel.margin.right || 0;
5831
5810
  let p = 0;
5832
5811
 
5833
5812
  for (let i = 0; i < count + 1; i++) {
@@ -6255,13 +6234,13 @@ System.register([], function (exports) {
6255
6234
 
6256
6235
  if (legendPosition == 'top' || legendPosition == 'bottom') {
6257
6236
  //顶部和底部图例横排,每次右移位一个单位图例
6258
- panel.position.x = this.width + 15 * this.graph.devicePixelRatio;
6237
+ panel.position.x = this.width + 15;
6259
6238
  this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
6260
6239
 
6261
6240
  this.height = Math.max(panel.height, this.height);
6262
6241
  } else {
6263
6242
  //右边和左边图例竖排
6264
- panel.position.y += this.height + 5 * this.graph.devicePixelRatio;
6243
+ panel.position.y += this.height + 5;
6265
6244
  this.height = panel.position.y + panel.height;
6266
6245
  this.width = Math.max(panel.width, this.width);
6267
6246
  }
@@ -6301,21 +6280,21 @@ System.register([], function (exports) {
6301
6280
  {
6302
6281
  this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
6303
6282
 
6304
- this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right * this.graph.devicePixelRatio;
6283
+ this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
6305
6284
  break;
6306
6285
  }
6307
6286
 
6308
6287
  case 'top':
6309
6288
  {
6310
6289
  this.graph.chartArea.height = this.graph.chartArea.height - this.height;
6311
- this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom * this.graph.devicePixelRatio;
6290
+ this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
6312
6291
  break;
6313
6292
  }
6314
6293
 
6315
6294
  case 'bottom':
6316
6295
  {
6317
6296
  this.graph.chartArea.height = this.graph.chartArea.height - this.height;
6318
- this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top * this.graph.devicePixelRatio;
6297
+ this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
6319
6298
  break;
6320
6299
  }
6321
6300
 
@@ -6323,7 +6302,7 @@ System.register([], function (exports) {
6323
6302
  default:
6324
6303
  {
6325
6304
  this.graph.chartArea.width = this.graph.chartArea.width - this.width;
6326
- this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left * this.graph.devicePixelRatio;
6305
+ this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
6327
6306
  break;
6328
6307
  }
6329
6308
  }
@@ -7070,7 +7049,7 @@ System.register([], function (exports) {
7070
7049
  x: this.graph.chartArea.width / 2,
7071
7050
  y: this.graph.chartArea.height / 2
7072
7051
  };
7073
- const radius = Math.min(center.x - this.style.margin.left * this.graph.devicePixelRatio - this.style.margin.right * this.graph.devicePixelRatio, center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio); //生成描点位
7052
+ const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right, center.y - this.style.margin.top - this.style.margin.bottom); //生成描点位
7074
7053
  // super.init会把参数透传给 createPoints
7075
7054
 
7076
7055
  const {
@@ -7436,7 +7415,7 @@ System.register([], function (exports) {
7436
7415
  x: this.graph.chartArea.width / 2,
7437
7416
  y: this.graph.chartArea.height / 2
7438
7417
  };
7439
- this.radius = Math.min(this.center.x - this.style.margin.left * this.graph.devicePixelRatio - this.style.margin.right * this.graph.devicePixelRatio, this.center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio);
7418
+ this.radius = Math.min(this.center.x - this.style.margin.left - this.style.margin.right, this.center.y - this.style.margin.top - this.style.margin.bottom);
7440
7419
  const axises = this.createAxises(this.center, this.radius); // 重置所有轴
7441
7420
  // 计算最大最小值
7442
7421
  // 当前需要先更新axis的边界值,轴好画图
@@ -8230,7 +8209,7 @@ System.register([], function (exports) {
8230
8209
  if (!p || typeof p.y === 'undefined') continue;
8231
8210
  this.markArc = graph.createShape('circle', {
8232
8211
  style: this.style,
8233
- radius: (this.style.radius || 5) * this.graph.devicePixelRatio
8212
+ radius: this.style.radius || 5
8234
8213
  });
8235
8214
  this.markArc.center.y = p.y;
8236
8215
  this.children.add(this.markArc);
@@ -8444,14 +8423,14 @@ System.register([], function (exports) {
8444
8423
  else lineTouching = 1;
8445
8424
  }
8446
8425
 
8447
- args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
8426
+ args.event && args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
8448
8427
 
8449
8428
  if (chart.style.markLine.lock) {
8450
8429
  // 标线状态一直禁用系统能力
8451
8430
  // 如果指定了锁定值,只需要一项符合要求就进行锁定
8452
8431
  if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8453
8432
  lineTouching = 1;
8454
- args.event.preventDefault(); // 阻止默认行为
8433
+ args.event && args.event.preventDefault && args.event.preventDefault(); // 阻止默认行为
8455
8434
  }
8456
8435
  }
8457
8436
 
@@ -8659,7 +8638,7 @@ System.register([], function (exports) {
8659
8638
  this.touchGraph.chartGraph = this;
8660
8639
  this.on('propertyChange', (name, args) => {
8661
8640
  if (['width', 'height'].includes(name)) {
8662
- this.touchGraph[name] = args.newValue / this.devicePixelRatio;
8641
+ this.touchGraph[name] = args.newValue;
8663
8642
  }
8664
8643
  }); // 把上层canvse事件传递给绘图层对象
8665
8644
 
@@ -8799,10 +8778,10 @@ System.register([], function (exports) {
8799
8778
 
8800
8779
 
8801
8780
  resetAreaPosition() {
8802
- this.chartArea.position.x = (this.style.margin.left || 0) * this.graph.devicePixelRatio;
8803
- this.chartArea.position.y = (this.style.margin.top || 0) * this.graph.devicePixelRatio;
8804
- const w = this.width - this.style.margin.right * this.graph.devicePixelRatio - this.chartArea.position.x;
8805
- const h = this.height - this.style.margin.bottom * this.graph.devicePixelRatio - this.chartArea.position.y;
8781
+ this.chartArea.position.x = this.style.margin.left || 0;
8782
+ this.chartArea.position.y = this.style.margin.top || 0;
8783
+ const w = this.width - this.style.margin.right - this.chartArea.position.x;
8784
+ const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
8806
8785
  this.chartArea.width = w;
8807
8786
  this.chartArea.height = h;
8808
8787
  }
package/example/line.html CHANGED
@@ -238,10 +238,10 @@
238
238
 
239
239
  // 创建点的标注
240
240
  function addPointMarkLabel(point) {
241
- const w = 40 * this.graph.devicePixelRatio;
242
- const h = 20 * this.graph.devicePixelRatio;
243
- const bottom = 20 * this.graph.devicePixelRatio;
244
- const arrowOffset = 10 * this.graph.devicePixelRatio;
241
+ const w = 40;
242
+ const h = 20;
243
+ const bottom = 20;
244
+ const arrowOffset = 10;
245
245
 
246
246
  // 标注图形左上角
247
247
  const p1 = {
package/example/vue.html CHANGED
@@ -59,8 +59,6 @@
59
59
  </div>
60
60
  <script type="module">
61
61
  import { vChart } from '../dist/jmchart.esm.js';
62
- //window.devicePixelRatio=1;
63
- //if(!window.devicePixelRatio || window.devicePixelRatio<2) window.devicePixelRatio = 2; // pc状态下默认指定为2
64
62
 
65
63
  const options = {
66
64
  //width: 800, // 可以这里指定,也可以VUE属性指定
@@ -238,7 +238,7 @@
238
238
 
239
239
  function addPointMark(point, serie, options) {
240
240
  const mark = serie.graph.createShape('circle', {
241
- radius: 6 * serie.graph.devicePixelRatio,
241
+ radius: 6,
242
242
  style: {
243
243
  fill: 'red',
244
244
  zIndex: 18,
@@ -250,11 +250,11 @@
250
250
  }
251
251
  // 创建点的标注
252
252
  function addPointMarkLabel(point, serie, options = {index:0}) {
253
- const w = 40 * serie.graph.devicePixelRatio;
254
- const h = 20 * serie.graph.devicePixelRatio;
255
- const arrowOffset = 10 * serie.graph.devicePixelRatio;
253
+ const w = 40;
254
+ const h = 20;
255
+ const arrowOffset = 10;
256
256
 
257
- const bottom = 20 * serie.graph.devicePixelRatio + (h + arrowOffset) * options.index;
257
+ const bottom = 20 + (h + arrowOffset) * options.index;
258
258
 
259
259
  // 标注图形左上角
260
260
  const p1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmchart",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "chart",
5
5
  "main": "./index.js",
6
6
  "directories": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/jiamao/jmchart#readme",
30
30
  "dependencies": {
31
- "jmgraph": "^3.1.95"
31
+ "jmgraph": "^3.1.97"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/core": "^7.10.2",
package/server.js CHANGED
@@ -31,7 +31,7 @@ esmWatcher.on('event', event => {
31
31
 
32
32
 
33
33
  let serverInstance = null;
34
- const port = process.env.PORT || 8800;
34
+ const port = process.env.PORT || 8801;
35
35
  const ip = process.env.IP || '127.0.0.1';
36
36
 
37
37
  startServer();
@@ -269,7 +269,7 @@ export default class jmAxis extends jmArrowLine {
269
269
  //var count = this.style.xLabel.count || this.data.length;
270
270
  //字符串轴。则显示每个标签
271
271
  const format = this.option.format || this.format;
272
- const top = (this.style.xLabel.margin.top || 0) * this.graph.devicePixelRatio;
272
+ const top = (this.style.xLabel.margin.top || 0);
273
273
  for(let i=0; i< this.data.length;i++) {
274
274
  const d = this.data[i];
275
275
  const v = d[this.field];
@@ -372,8 +372,8 @@ export default class jmAxis extends jmArrowLine {
372
372
  let pervalue = (mm / count) || 1;
373
373
 
374
374
  const format = this.option.format || this.format;
375
- const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
376
- const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
375
+ const marginLeft = this.style.yLabel.margin.left || 0;
376
+ const marginRight = this.style.yLabel.margin.right || 0;
377
377
  let p = 0;
378
378
 
379
379
  for(let i=0; i<count+1; i++) {
@@ -79,13 +79,13 @@ jmLegend.prototype.append = function(series, shape, options = {}) {
79
79
  const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
80
80
  if(legendPosition == 'top' || legendPosition == 'bottom') {
81
81
  //顶部和底部图例横排,每次右移位一个单位图例
82
- panel.position.x = this.width + 15 * this.graph.devicePixelRatio;
82
+ panel.position.x = this.width + 15;
83
83
  this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
84
84
  this.height = Math.max(panel.height, this.height);
85
85
  }
86
86
  else {
87
87
  //右边和左边图例竖排
88
- panel.position.y += this.height + 5 * this.graph.devicePixelRatio;
88
+ panel.position.y += this.height + 5;
89
89
  this.height = panel.position.y + panel.height;
90
90
  this.width = Math.max(panel.width, this.width);
91
91
  }
@@ -122,23 +122,23 @@ jmLegend.prototype.reset = function() {
122
122
  case 'left': {
123
123
  this.graph.chartArea.width = this.graph.chartArea.width - this.width;
124
124
  //画图区域向右偏移
125
- this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right * this.graph.devicePixelRatio;
125
+ this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
126
126
  break;
127
127
  }
128
128
  case 'top': {
129
129
  this.graph.chartArea.height = this.graph.chartArea.height - this.height;
130
- this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom * this.graph.devicePixelRatio;
130
+ this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
131
131
  break;
132
132
  }
133
133
  case 'bottom': {
134
134
  this.graph.chartArea.height = this.graph.chartArea.height - this.height;
135
- this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top * this.graph.devicePixelRatio;
135
+ this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
136
136
  break;
137
137
  }
138
138
  case 'right':
139
139
  default: {
140
140
  this.graph.chartArea.width = this.graph.chartArea.width - this.width;
141
- this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left * this.graph.devicePixelRatio;
141
+ this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
142
142
  break;
143
143
  }
144
144
  }
@@ -107,7 +107,7 @@ export default class jmMarkLineManager {
107
107
  else lineTouching = 1;
108
108
  }
109
109
 
110
- args.event.stopPropagation && args.event.stopPropagation();
110
+ args.event && args.event.stopPropagation && args.event.stopPropagation();
111
111
  // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
112
112
  if(chart.style.markLine.lock){
113
113
  // 标线状态一直禁用系统能力
@@ -118,7 +118,7 @@ export default class jmMarkLineManager {
118
118
  || lineTouching === 1) {
119
119
 
120
120
  lineTouching = 1;
121
- args.event.preventDefault(); // 阻止默认行为
121
+ args.event && args.event.preventDefault && args.event.preventDefault(); // 阻止默认行为
122
122
  }
123
123
  }
124
124
 
@@ -73,7 +73,7 @@ export default class jmMarkLine extends jmLine {
73
73
  if(!p || typeof p.y === 'undefined') continue;
74
74
  this.markArc = graph.createShape('circle', {
75
75
  style: this.style,
76
- radius: (this.style.radius || 5) * this.graph.devicePixelRatio
76
+ radius: (this.style.radius || 5)
77
77
  });
78
78
 
79
79
  this.markArc.center.y = p.y;
package/src/jmChart.js CHANGED
@@ -158,7 +158,7 @@ export default class jmChart extends jmGraph {
158
158
 
159
159
  this.on('propertyChange', (name, args) => {
160
160
  if(['width', 'height'].includes(name)) {
161
- this.touchGraph[name] = args.newValue / this.devicePixelRatio;
161
+ this.touchGraph[name] = args.newValue;
162
162
  }
163
163
  });
164
164
  // 把上层canvse事件传递给绘图层对象
@@ -290,10 +290,10 @@ export default class jmChart extends jmGraph {
290
290
  * @method resetAreaPosition
291
291
  */
292
292
  resetAreaPosition() {
293
- this.chartArea.position.x = (this.style.margin.left || 0) * this.graph.devicePixelRatio;
294
- this.chartArea.position.y = (this.style.margin.top || 0) * this.graph.devicePixelRatio;
295
- const w = this.width - (this.style.margin.right * this.graph.devicePixelRatio) - this.chartArea.position.x;
296
- const h = this.height - (this.style.margin.bottom * this.graph.devicePixelRatio) - this.chartArea.position.y;
293
+ this.chartArea.position.x = (this.style.margin.left || 0);
294
+ this.chartArea.position.y = (this.style.margin.top || 0);
295
+ const w = this.width - this.style.margin.right - this.chartArea.position.x;
296
+ const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
297
297
 
298
298
  this.chartArea.width = w;
299
299
  this.chartArea.height = h;
@@ -43,9 +43,9 @@ export default class jmPieSeries extends jmSeries {
43
43
  y: this.graph.chartArea.height / 2
44
44
  };
45
45
 
46
- const radius = Math.min(center.x - this.style.margin.left * this.graph.devicePixelRatio -
47
- this.style.margin.right * this.graph.devicePixelRatio,
48
- center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio);
46
+ const radius = Math.min(center.x - this.style.margin.left -
47
+ this.style.margin.right,
48
+ center.y - this.style.margin.top - this.style.margin.bottom);
49
49
 
50
50
 
51
51
  //生成描点位
@@ -86,9 +86,9 @@ export default class jmRadarSeries extends jmSeries {
86
86
  y: this.graph.chartArea.height / 2
87
87
  };
88
88
 
89
- this.radius = Math.min(this.center.x - this.style.margin.left * this.graph.devicePixelRatio -
90
- this.style.margin.right * this.graph.devicePixelRatio,
91
- this.center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio);
89
+ this.radius = Math.min(this.center.x - this.style.margin.left -
90
+ this.style.margin.right,
91
+ this.center.y - this.style.margin.top - this.style.margin.bottom);
92
92
 
93
93
  const axises = this.createAxises(this.center, this.radius);// 重置所有轴
94
94
  // 计算最大最小值