tvcharts 0.7.98 → 0.8.1

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.
@@ -77,30 +77,59 @@ var LinePlotPath = /** @class */function (_super) {
77
77
  return new LinePlotShape();
78
78
  };
79
79
  LinePlotPath.prototype.buildPath = function (ctx, shape) {
80
- var points = shape.points;
81
- for (var index = 0; index < points.length; index++) {
82
- var point = points[index];
83
- // if (isPointNull(point) && connectNulls) {
84
- // continue
85
- // }
86
- if (point === 0 || isPointNull(point)) {
87
- var nextPoint = points[++index];
88
- while ((nextPoint === 0 || isPointNull(nextPoint)) && index < points.length) {
89
- nextPoint = points[++index];
80
+ var points = shape.points,
81
+ connectSelf = shape.connectSelf,
82
+ barWidth = shape.barWidth;
83
+ if (connectSelf) {
84
+ var offset = barWidth / 2;
85
+ var isMove = false;
86
+ for (var index = 0; index < points.length; index++) {
87
+ var point = points[index];
88
+ if (point === 0 || isPointNull(point)) {
89
+ isMove = true;
90
+ continue;
91
+ }
92
+ if (isMove) {
93
+ var nextPoint = points[index + 1];
94
+ var _a = point,
95
+ x = _a[0],
96
+ y = _a[1];
97
+ if (!nextPoint || isPointNull(nextPoint)) {
98
+ ctx.moveTo(x - offset, y);
99
+ ctx.lineTo(x + offset, y);
100
+ continue;
101
+ }
102
+ ctx.moveTo(x, y);
103
+ isMove = false;
104
+ } else {
105
+ var _b = point,
106
+ x = _b[0],
107
+ y = _b[1];
108
+ ctx.lineTo(x, y);
90
109
  }
91
- if (!nextPoint) {
110
+ }
111
+ } else {
112
+ for (var index = 0; index < points.length; index++) {
113
+ var point = points[index];
114
+ if (point === 0 || isPointNull(point)) {
115
+ var nextPoint = points[++index];
116
+ while ((nextPoint === 0 || isPointNull(nextPoint)) && index < points.length) {
117
+ nextPoint = points[++index];
118
+ }
119
+ if (!nextPoint) {
120
+ continue;
121
+ }
122
+ var _c = nextPoint,
123
+ x_1 = _c[0],
124
+ y_1 = _c[1];
125
+ ctx.moveTo(x_1, y_1);
92
126
  continue;
93
127
  }
94
- var _a = nextPoint,
95
- x_1 = _a[0],
96
- y_1 = _a[1];
97
- ctx.moveTo(x_1, y_1);
98
- continue;
128
+ var _d = point,
129
+ x = _d[0],
130
+ y = _d[1];
131
+ ctx.lineTo(x, y);
99
132
  }
100
- var _b = point,
101
- x = _b[0],
102
- y = _b[1];
103
- ctx.lineTo(x, y);
104
133
  }
105
134
  };
106
135
  return LinePlotPath;
@@ -292,6 +292,9 @@ var LinesPlotView = /** @class */function (_super) {
292
292
  // return;
293
293
  // }
294
294
  var visualColor_1 = getVisualGradient(data, seriesModel.coordinateSystem, api);
295
+ var connectNulls_1 = seriesModel.get('connectNulls');
296
+ var step_1 = seriesModel.get('step');
297
+ var barSpace_1 = Math.floor((seriesModel.coordinateSystem.getAxesByScale('ordinal')[0].scale.barSpace || calculatebandWidth(seriesModel, data)) * 0.8) || 1;
295
298
  each(linePointsByKey, function (item, key) {
296
299
  var _a = key.split(':'),
297
300
  stroke = _a[0],
@@ -305,7 +308,9 @@ var LinesPlotView = /** @class */function (_super) {
305
308
  }
306
309
  var el = new LinePlotPath({
307
310
  shape: {
308
- points: item
311
+ points: item,
312
+ connectSelf: !connectNulls_1 && !step_1,
313
+ barWidth: barSpace_1
309
314
  },
310
315
  style: {
311
316
  lineDash: lineDash,
@@ -147,6 +147,45 @@ var OrdinalMeta = /** @class */function () {
147
147
  OrdinalMeta.prototype.getMarksByWeight = function () {
148
148
  return this._marksByWeight;
149
149
  };
150
+ OrdinalMeta.prototype.reFillExtraCategories = function (startTime) {
151
+ var timePoints = [];
152
+ var marksByWeight = new HashMap();
153
+ var formatInterval = this.dataInterval === '1D';
154
+ var utcOffsetTime = this.utcOffsetTime;
155
+ var addItem = function (value, index) {
156
+ var d = formatInterval ? convertToUTCDayStart(value - utcOffsetTime) : value * 1000;
157
+ timePoints.push({
158
+ originalTime: value,
159
+ index: index,
160
+ timestamp: d / 1000
161
+ });
162
+ };
163
+ var categories = this.categories;
164
+ each(categories, function (val, index) {
165
+ addItem(val, index);
166
+ });
167
+ var extraCategory = this.loadMoreCategory(startTime, 300);
168
+ map(extraCategory, function (val, i) {
169
+ var index = i + categories.length;
170
+ addItem(val, index);
171
+ });
172
+ if (timePoints.length) {
173
+ fillWeightsForPoints(timePoints);
174
+ for (var index = 0; index < timePoints.length; ++index) {
175
+ var point = timePoints[index];
176
+ var marksForWeight = marksByWeight.get(point.weight);
177
+ if (marksForWeight === undefined) {
178
+ marksForWeight = [];
179
+ marksByWeight.set(point.weight, marksForWeight);
180
+ }
181
+ marksForWeight.push(point);
182
+ }
183
+ }
184
+ this.extraCategory = extraCategory;
185
+ this._marksByWeight = marksByWeight;
186
+ this._appendCount = 0;
187
+ this.cache = null;
188
+ };
150
189
  OrdinalMeta.prototype.appendData = function (data) {
151
190
  var _a;
152
191
  var _this = this;
@@ -157,6 +196,11 @@ var OrdinalMeta = /** @class */function () {
157
196
  });
158
197
  }
159
198
  (_a = this.categories).push.apply(_a, data);
199
+ var lastUpdateTime = +data[data.length - 1];
200
+ if (lastUpdateTime !== +this.extraCategory[0]) {
201
+ this.reFillExtraCategories(lastUpdateTime);
202
+ return;
203
+ }
160
204
  this.extraCategory.splice(0, data.length);
161
205
  if (this.loadMoreCategory) {
162
206
  var startTime = this.extraCategory[this.extraCategory.length - 1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.7.98",
3
+ "version": "0.8.01",
4
4
  "description": "基于echarts5.5.0二次开发",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -2648,7 +2648,7 @@ interface MarksCache {
2648
2648
  }
2649
2649
  declare class OrdinalMeta {
2650
2650
  readonly categories: OrdinalRawValue[];
2651
- readonly extraCategory: OrdinalRawValue[];
2651
+ extraCategory: OrdinalRawValue[];
2652
2652
  private loadMoreCategory;
2653
2653
  cache: MarksCache | null;
2654
2654
  private _marksByWeight;
@@ -2672,6 +2672,7 @@ declare class OrdinalMeta {
2672
2672
  static createByAxisModel(axisModel: Model): OrdinalMeta;
2673
2673
  getOrdinal(category: OrdinalRawValue): OrdinalNumber;
2674
2674
  getMarksByWeight(): HashMap<TimePoint[], string | number>;
2675
+ reFillExtraCategories(startTime: number): void;
2675
2676
  appendData(data: string[]): void;
2676
2677
  getCategories(): OrdinalRawValue[];
2677
2678
  getClosestTime(time: string): number;
@@ -2648,7 +2648,7 @@ interface MarksCache {
2648
2648
  }
2649
2649
  declare class OrdinalMeta {
2650
2650
  readonly categories: OrdinalRawValue[];
2651
- readonly extraCategory: OrdinalRawValue[];
2651
+ extraCategory: OrdinalRawValue[];
2652
2652
  private loadMoreCategory;
2653
2653
  cache: MarksCache | null;
2654
2654
  private _marksByWeight;
@@ -2672,6 +2672,7 @@ declare class OrdinalMeta {
2672
2672
  static createByAxisModel(axisModel: Model): OrdinalMeta;
2673
2673
  getOrdinal(category: OrdinalRawValue): OrdinalNumber;
2674
2674
  getMarksByWeight(): HashMap<TimePoint[], string | number>;
2675
+ reFillExtraCategories(startTime: number): void;
2675
2676
  appendData(data: string[]): void;
2676
2677
  getCategories(): OrdinalRawValue[];
2677
2678
  getClosestTime(time: string): number;
@@ -5,6 +5,8 @@ import * as graphic from '../../util/graphic.js';
5
5
  import { PathProps } from 'tvrender/lib/graphic/Path.js';
6
6
  declare class LinePlotShape {
7
7
  points: (number | number[])[];
8
+ connectSelf?: boolean;
9
+ barWidth?: number;
8
10
  }
9
11
  interface ECLineProps extends PathProps {
10
12
  shape: LinePlotShape;
@@ -8,7 +8,7 @@ interface MarksCache {
8
8
  }
9
9
  declare class OrdinalMeta {
10
10
  readonly categories: OrdinalRawValue[];
11
- readonly extraCategory: OrdinalRawValue[];
11
+ extraCategory: OrdinalRawValue[];
12
12
  private loadMoreCategory;
13
13
  cache: MarksCache | null;
14
14
  private _marksByWeight;
@@ -32,6 +32,7 @@ declare class OrdinalMeta {
32
32
  static createByAxisModel(axisModel: Model): OrdinalMeta;
33
33
  getOrdinal(category: OrdinalRawValue): OrdinalNumber;
34
34
  getMarksByWeight(): HashMap<TimePoint[], string | number>;
35
+ reFillExtraCategories(startTime: number): void;
35
36
  appendData(data: string[]): void;
36
37
  getCategories(): OrdinalRawValue[];
37
38
  getClosestTime(time: string): number;