tvcharts 0.6.93 → 0.6.94

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.
@@ -99,13 +99,14 @@ var bgColorLayout = {
99
99
  var rects = rectsByColor[color] || [];
100
100
  rects.push({
101
101
  x: Math.floor(xPx - leftOffset),
102
- y: startY,
103
- width: width,
104
- height: height
102
+ y: startY
105
103
  });
106
104
  rectsByColor[color] = rects;
107
105
  }
108
- bgColorData.setLayout('rectsByColor', rectsByColor);
106
+ bgColorData.setLayout({
107
+ rectsByColor: rectsByColor,
108
+ height: height
109
+ });
109
110
  }
110
111
  };
111
112
  }
@@ -45,11 +45,13 @@ import { __extends } from "tslib";
45
45
  /**
46
46
  * Line path for bezier and straight line draw
47
47
  */
48
- import * as graphic from "../../util/graphic.js";
48
+ import * as graphic from '../../util/graphic.js';
49
49
  var BgColorShape = /** @class */function () {
50
50
  function BgColorShape() {
51
51
  this.points = [];
52
52
  this.isLine = false;
53
+ this.width = 2;
54
+ this.height = 2;
53
55
  }
54
56
  return BgColorShape;
55
57
  }();
@@ -57,13 +59,13 @@ var BgColorPath = /** @class */function (_super) {
57
59
  __extends(BgColorPath, _super);
58
60
  function BgColorPath(opts) {
59
61
  var _this = _super.call(this, opts) || this;
60
- _this.type = "BarPlot";
62
+ _this.type = 'BarPlot';
61
63
  return _this;
62
64
  }
63
65
  BgColorPath.prototype.getDefaultStyle = function () {
64
66
  return {
65
- stroke: "transparent",
66
- fill: "#000"
67
+ stroke: 'transparent',
68
+ fill: '#000'
67
69
  };
68
70
  };
69
71
  BgColorPath.prototype.getDefaultShape = function () {
@@ -71,13 +73,14 @@ var BgColorPath = /** @class */function (_super) {
71
73
  };
72
74
  BgColorPath.prototype.buildPath = function (ctx, shape) {
73
75
  var points = shape.points,
74
- isLine = shape.isLine;
76
+ isLine = shape.isLine,
77
+ width = shape.width,
78
+ height = shape.height;
75
79
  if (isLine) {
76
80
  for (var index = 0; index < points.length; index++) {
77
81
  var point = points[index];
78
82
  var x = point.x,
79
- y = point.y,
80
- height = point.height;
83
+ y = point.y;
81
84
  ctx.moveTo(x, y);
82
85
  ctx.lineTo(x, y + height);
83
86
  }
@@ -85,9 +88,7 @@ var BgColorPath = /** @class */function (_super) {
85
88
  for (var index = 0; index < points.length; index++) {
86
89
  var point = points[index];
87
90
  var x = point.x,
88
- y = point.y,
89
- width = point.width,
90
- height = point.height;
91
+ y = point.y;
91
92
  ctx.rect(x, y, width, height);
92
93
  }
93
94
  }
@@ -43,11 +43,11 @@
43
43
  */
44
44
  import { __extends } from "tslib";
45
45
  // FIXME step not support polar
46
- import { each } from "tvrender/lib/core/util.js";
47
- import ChartView from "../../view/Chart.js";
48
- import * as graphic from "../../util/graphic.js";
49
- import { createClipPath } from "../helper/createClipPathFromCoordSys.js";
50
- import BgColorPath from "./BgColorPath.js";
46
+ import { each } from 'tvrender/lib/core/util.js';
47
+ import ChartView from '../../view/Chart.js';
48
+ import * as graphic from '../../util/graphic.js';
49
+ import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
50
+ import BgColorPath from './BgColorPath.js';
51
51
  var BgColorView = /** @class */function (_super) {
52
52
  __extends(BgColorView, _super);
53
53
  function BgColorView() {
@@ -61,7 +61,8 @@ var BgColorView = /** @class */function (_super) {
61
61
  // }
62
62
  BgColorView.prototype.render = function (seriesModel, ecModel, api) {
63
63
  var data = seriesModel.getData();
64
- var rectsByColor = data.getLayout("rectsByColor");
64
+ var rectsByColor = data.getLayout('rectsByColor');
65
+ var height = data.getLayout('height');
65
66
  if (!this._bgColorGroup) {
66
67
  this._bgColorGroup = new graphic.Group();
67
68
  this.group.add(this._bgColorGroup);
@@ -69,23 +70,25 @@ var BgColorView = /** @class */function (_super) {
69
70
  this._bgColorGroup.removeAll();
70
71
  }
71
72
  var bgColorGroup = this._bgColorGroup;
72
- var width = Math.ceil(seriesModel.coordinateSystem.getBaseAxis().scale.barSpace);
73
- var isLine = width <= 8;
73
+ var width = Math.ceil(seriesModel.coordinateSystem.getBaseAxis().scale.barSpace) || 5;
74
+ var isLine = width <= 2;
74
75
  each(rectsByColor, function (rects, color) {
75
76
  var el = new BgColorPath({
76
77
  shape: {
77
78
  points: rects,
78
- isLine: isLine
79
+ isLine: isLine,
80
+ width: width,
81
+ height: height
79
82
  },
80
83
  style: {
81
84
  fill: isLine ? null : color,
82
- stroke: isLine ? color : "transparent",
85
+ stroke: isLine ? color : 'transparent',
83
86
  lineWidth: isLine ? width : void 0
84
87
  }
85
88
  });
86
89
  bgColorGroup.add(el);
87
90
  });
88
- var clipPath = seriesModel.get("clip", true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
91
+ var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
89
92
  if (clipPath) {
90
93
  this.group.setClipPath(clipPath);
91
94
  } else {
@@ -104,7 +107,7 @@ var BgColorView = /** @class */function (_super) {
104
107
  BgColorView.prototype.dispose = function (ecModel, api) {
105
108
  this.remove(ecModel, api);
106
109
  };
107
- BgColorView.type = "bgcolor";
110
+ BgColorView.type = 'bgcolor';
108
111
  return BgColorView;
109
112
  }(ChartView);
110
113
  export default BgColorView;
@@ -246,8 +246,9 @@ export function fixValue(axisModel) {
246
246
  var option = axisPointerModel.option;
247
247
  var status = axisPointerModel.get('status');
248
248
  var value = axisPointerModel.get('value');
249
+ var isPercentage = scale.type === 'percentage';
249
250
  // Parse init value for category and time axis.
250
- if (value != null) {
251
+ if (value != null && !isPercentage) {
251
252
  value = scale.parse(value);
252
253
  }
253
254
  var useHandle = isHandleTrigger(axisPointerModel);
@@ -256,19 +257,21 @@ export function fixValue(axisModel) {
256
257
  if (status == null) {
257
258
  option.status = useHandle ? 'show' : 'hide';
258
259
  }
259
- var extent = scale.getExtent().slice();
260
- extent[0] > extent[1] && extent.reverse();
261
- if (
262
- // Pick a value on axis when initializing.
263
- value == null
264
- // If both `handle` and `dataZoom` are used, value may be out of axis extent,
265
- // where we should re-pick a value to keep `handle` displaying normally.
266
- || value > extent[1]) {
267
- // Make handle displayed on the end of the axis when init, which looks better.
268
- value = extent[1];
269
- }
270
- if (value < extent[0]) {
271
- value = extent[0];
260
+ if (!isPercentage) {
261
+ var extent = scale.getExtent().slice();
262
+ extent[0] > extent[1] && extent.reverse();
263
+ if (
264
+ // Pick a value on axis when initializing.
265
+ value == null
266
+ // If both `handle` and `dataZoom` are used, value may be out of axis extent,
267
+ // where we should re-pick a value to keep `handle` displaying normally.
268
+ || value > extent[1]) {
269
+ // Make handle displayed on the end of the axis when init, which looks better.
270
+ value = extent[1];
271
+ }
272
+ if (value < extent[0]) {
273
+ value = extent[0];
274
+ }
272
275
  }
273
276
  option.value = value;
274
277
  if (useHandle) {
@@ -369,7 +369,7 @@ var Grid = /** @class */function () {
369
369
  }, this);
370
370
  function unionExtent(data, axis) {
371
371
  var axisDims = getDataDimensionsOnAxis(data, axis.dim);
372
- var baseDim = axisDims.includes("close") ? 'close' : 'y';
372
+ var baseDim = axisDims.includes('close') ? 'close' : 'y';
373
373
  var baseValue = data.get(baseDim, 0);
374
374
  each(axisDims, function (dim) {
375
375
  axis.scale.unionExtentFromData(data, dim, baseValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.6.93",
3
+ "version": "0.6.94",
4
4
  "description": "基于echarts5.5.0二次开发",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Line path for bezier and straight line draw
3
3
  */
4
- import * as graphic from "../../util/graphic.js";
5
- import { PathProps } from "tvrender/lib/graphic/Path.js";
4
+ import * as graphic from '../../util/graphic.js';
5
+ import { PathProps } from 'tvrender/lib/graphic/Path.js';
6
6
  declare class BgColorShape {
7
7
  points: {
8
8
  x: number;
9
9
  y: number;
10
- width: number;
11
- height: number;
12
10
  }[];
13
11
  isLine: boolean;
12
+ width: number;
13
+ height: number;
14
14
  }
15
15
  interface BgColorProps extends PathProps {
16
16
  shape: BgColorShape;
@@ -1,8 +1,8 @@
1
- import ChartView from "../../view/Chart.js";
2
- import HLinesSeriesModel from "./BgColorSeries.js";
3
- import type GlobalModel from "../../model/Global.js";
4
- import type ExtensionAPI from "../../core/ExtensionAPI.js";
5
- import Element from "tvrender/lib/Element.js";
1
+ import ChartView from '../../view/Chart.js';
2
+ import HLinesSeriesModel from './BgColorSeries.js';
3
+ import type GlobalModel from '../../model/Global.js';
4
+ import type ExtensionAPI from '../../core/ExtensionAPI.js';
5
+ import Element from 'tvrender/lib/Element.js';
6
6
  declare class BgColorView extends ChartView {
7
7
  static readonly type = "bgcolor";
8
8
  readonly type = "bgcolor";