tvcharts 0.6.71 → 0.6.73

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.
package/dist/echarts.js CHANGED
@@ -21566,6 +21566,64 @@ var ECEventProcessor = class {
21566
21566
  }
21567
21567
  };
21568
21568
 
21569
+ // src/data/scale-time/find-time-range.ts
21570
+ function lowerBound(arr, target) {
21571
+ let left = 0;
21572
+ let right = arr.length - 1;
21573
+ while (left <= right) {
21574
+ const mid = Math.floor((left + right) / 2);
21575
+ if (arr[mid] < target) {
21576
+ left = mid + 1;
21577
+ } else {
21578
+ right = mid - 1;
21579
+ }
21580
+ }
21581
+ return left;
21582
+ }
21583
+ function upperBound(arr, target) {
21584
+ let left = 0;
21585
+ let right = arr.length - 1;
21586
+ while (left <= right) {
21587
+ const mid = Math.floor((left + right) / 2);
21588
+ if (arr[mid] <= target) {
21589
+ left = mid + 1;
21590
+ } else {
21591
+ right = mid - 1;
21592
+ }
21593
+ }
21594
+ return right;
21595
+ }
21596
+ function getIndexRange(arr, start2, end2) {
21597
+ const lowerIndex = lowerBound(arr, start2);
21598
+ const upperIndex = upperBound(arr, end2);
21599
+ return [lowerIndex, upperIndex];
21600
+ }
21601
+ function findClosestTimestamp(arr, target) {
21602
+ let left = 0;
21603
+ let right = arr.length - 1;
21604
+ if (arr.length === 0) {
21605
+ return "";
21606
+ }
21607
+ ;
21608
+ while (left < right) {
21609
+ const mid = Math.floor((left + right) / 2);
21610
+ if (arr[mid] === target) {
21611
+ return arr[mid];
21612
+ } else if (arr[mid] < target) {
21613
+ left = mid + 1;
21614
+ } else {
21615
+ right = mid;
21616
+ }
21617
+ }
21618
+ const leftClosest = arr[left];
21619
+ const rightClosest = left > 0 ? arr[left - 1] : void 0;
21620
+ if (rightClosest === void 0) {
21621
+ return leftClosest;
21622
+ }
21623
+ ;
21624
+ return Math.abs(+leftClosest - +target) <= Math.abs(+rightClosest - +target) ? leftClosest : rightClosest;
21625
+ }
21626
+
21569
21627
  // src/visual/symbol.ts
21570
21628
  var SYMBOL_PROPS_WITH_CB = [
21571
21629
  "symbol",
@@ -24078,6 +24136,9 @@ var ECharts = class extends Eventful_default {
24078
24136
  getModel() {
24079
24137
  return this._model;
24080
24138
  }
24139
+ getMessageCenter() {
24140
+ return this._messageCenter;
24141
+ }
24081
24142
  getOption(key) {
24082
24143
  return this._model && this._model.getOption(key);
24083
24144
  }
@@ -24392,7 +24453,7 @@ var ECharts = class extends Eventful_default {
24392
24453
  this.trigger(eventType, event);
24393
24454
  }, this);
24394
24455
  });
24395
- each(["selectchanged", "selectitem", "loadmore", "zoomend"], (eventType) => {
24456
+ each(["selectchanged", "selectitem", "loadmore", "zoomend", "visiblechanged"], (eventType) => {
24396
24457
  this._messageCenter.on(eventType, function(event) {
24397
24458
  this.trigger(eventType, event);
24398
24459
  }, this);
@@ -24516,6 +24577,63 @@ var ECharts = class extends Eventful_default {
24516
24577
  payload.type = eventActionMap[eventObj.type];
24517
24578
  return payload;
24518
24579
  }
24580
+ makeLayoutActionFromEvent(eventObj, type) {
24581
+ let payload = eventObj;
24582
+ console.log("%c [ eventObj ]-1513", "font-size:13px; background:pink; color:#bf2c9f;", eventObj);
24583
+ switch (type) {
24584
+ case "visiblechanged":
24585
+ const {fromTime, toTime, offsetRightDistance, offsetLeftDistance} = eventObj;
24586
+ const xAxisModal = this._model.getComponent("xAxis", 0);
24587
+ const scale4 = xAxisModal.axis.scale;
24588
+ const categories = scale4.getOrdinalMeta().getCategories();
24589
+ const dataCount = categories.length;
24590
+ const [startIndex, endIndex] = getIndexRange(categories, fromTime, toTime);
24591
+ const axisLength = xAxisModal.axis.getExtent()[1];
24592
+ const width = axisLength - offsetRightDistance - offsetLeftDistance;
24593
+ let barCount = endIndex - startIndex;
24594
+ let barSpace = Math.max(1, width / barCount);
24595
+ let lastBarRightSideDiffBarCount = endIndex - dataCount + 0.5 + offsetRightDistance / barSpace;
24596
+ if (endIndex < 0) {
24597
+ barCount = dataCount;
24598
+ barSpace = Math.max(1, axisLength / barCount);
24599
+ lastBarRightSideDiffBarCount = endIndex - dataCount + 0.5;
24600
+ } else if (barCount < 2) {
24601
+ barCount = 2;
24602
+ barSpace = Math.max(1, axisLength / barCount);
24603
+ lastBarRightSideDiffBarCount = endIndex - dataCount + 0.5;
24604
+ }
24605
+ const maxRightOffsetBarCount = barCount - Math.min(2, dataCount);
24606
+ if (lastBarRightSideDiffBarCount > maxRightOffsetBarCount) {
24607
+ lastBarRightSideDiffBarCount = maxRightOffsetBarCount;
24608
+ }
24609
+ const minRightOffsetBarCount = -dataCount + Math.min(2, dataCount);
24610
+ if (lastBarRightSideDiffBarCount < minRightOffsetBarCount) {
24611
+ lastBarRightSideDiffBarCount = minRightOffsetBarCount;
24612
+ }
24613
+ payload = {
24614
+ type: "dataZoom",
24615
+ dataZoomIndex: 0,
24616
+ barSpace,
24617
+ lastBarRightSideDiffBarCount
24618
+ };
24619
+ break;
24620
+ case "updateaxispointer":
24621
+ if (payload.axesInfo) {
24622
+ payload.axesInfo.find((item) => {
24623
+ const isXAxis = item.axisDim === "x" && item.time;
24624
+ if (isXAxis) {
24625
+ const xAxisModal2 = this._model.getComponent("xAxis", 0);
24626
+ const scale5 = xAxisModal2.axis.scale;
24627
+ item.value = scale5.getOrdinalMeta().getClosestTime(item.time);
24628
+ payload.dataIndex = item.value;
24629
+ }
24630
+ return isXAxis;
24631
+ });
24632
+ }
24633
+ break;
24634
+ }
24635
+ return payload;
24636
+ }
24519
24637
  dispatchAction(payload, opt) {
24520
24638
  if (this._disposed) {
24521
24639
  disposedWarning(this.id);
@@ -24581,8 +24699,8 @@ var ECharts = class extends Eventful_default {
24581
24699
  return;
24582
24700
  }
24583
24701
  const seriesModel = seriesIndex !== void 0 ? ecModel.getSeriesByIndex(seriesIndex) : ecModel.getSeriesByName(seriesName)[0];
24584
- if (true) {
24585
- assert(params.data && seriesModel);
24702
+ if (!seriesModel) {
24703
+ return;
24586
24704
  }
24587
24705
  const seriesData = seriesModel.getData();
24588
24706
  const lastIndex = seriesData.count(true) - 1;
@@ -25551,7 +25669,7 @@ ECharts.internalField = function() {
25551
25669
  }
25552
25670
  each(layoutEventActionMap, function(actionType, eventType) {
25553
25671
  chart._messageCenter.on(eventType, function(event) {
25554
- if (connectedLayouts[chart.layout] && chart[CONNECT_LAYOUT_STATUS_KEY] !== CONNECT_STATUS_PENDING) {
25672
+ if ((eventType === "visiblechanged" ? chart.selected : true) && connectedLayouts[chart.layout] && chart[CONNECT_LAYOUT_STATUS_KEY] !== CONNECT_STATUS_PENDING && layoutEventAbleMap[chart.layout].includes(eventType)) {
25555
25673
  if (event && event.escapeConnect) {
25556
25674
  return;
25557
25675
  }
@@ -25565,7 +25683,8 @@ ECharts.internalField = function() {
25565
25683
  updateConnectedChartsStatus(otherCharts, CONNECT_STATUS_PENDING);
25566
25684
  each(otherCharts, function(otherChart) {
25567
25685
  if (otherChart[CONNECT_LAYOUT_STATUS_KEY] !== CONNECT_STATUS_UPDATING) {
25568
- otherChart.dispatchAction(action);
25686
+ const formatAction = otherChart.makeLayoutActionFromEvent(action, eventType);
25687
+ otherChart.dispatchAction(formatAction);
25569
25688
  }
25570
25689
  });
25571
25690
  updateConnectedChartsStatus(otherCharts, CONNECT_STATUS_UPDATED);
@@ -25606,8 +25725,10 @@ function disposedWarning(id) {
25606
25725
  var actions = {};
25607
25726
  var eventActionMap = {};
25608
25727
  var layoutEventActionMap = {
25609
- updateaxispointer: "updateAxisPointer"
25728
+ updateaxispointer: "updateAxisPointer",
25729
+ visiblechanged: "visiblechanged"
25610
25730
  };
25731
+ var layoutEventAbleMap = {};
25611
25732
  var dataProcessorFuncs = [];
25612
25733
  var optionPreprocessorFuncs = [];
25613
25734
  var visualFuncs = [];
@@ -25669,8 +25790,9 @@ function connect(groupId) {
25669
25790
  function disconnect(groupId) {
25670
25791
  connectedGroups[groupId] = false;
25671
25792
  }
25672
- function connectLayouts(layoutId) {
25793
+ function connectLayouts(layoutId, actionAuth) {
25673
25794
  connectedLayouts[layoutId] = true;
25795
+ layoutEventAbleMap[layoutId] = actionAuth;
25674
25796
  return layoutId;
25675
25797
  }
25676
25798
  function disconnectLayouts(layoutId) {
@@ -27617,6 +27739,7 @@ var OrdinalMeta = class {
27617
27739
  this._needCollect = opt.needCollect;
27618
27740
  this._deduplication = opt.deduplication;
27619
27741
  this._marksByWeight = opt.marksByWeight;
27742
+ this.interval = opt.interval;
27620
27743
  this.cache = null;
27621
27744
  this.uid = ++uidBase;
27622
27745
  }
@@ -27667,7 +27790,8 @@ var OrdinalMeta = class {
27667
27790
  extraCategory,
27668
27791
  deduplication: option.dedplication !== false,
27669
27792
  loadMoreCategory: option.loadMoreCategory,
27670
- marksByWeight
27793
+ marksByWeight,
27794
+ interval: option.interval
27671
27795
  });
27672
27796
  return ins;
27673
27797
  }
@@ -27718,6 +27842,13 @@ var OrdinalMeta = class {
27718
27842
  }
27719
27843
  }
27720
27844
  }
27845
+ getCategories() {
27846
+ return this.categories;
27847
+ }
27848
+ getClosestTime(time) {
27849
+ const findTime = findClosestTimestamp(this.categories, time);
27850
+ return this.getOrdinal(findTime);
27851
+ }
27721
27852
  getLastCategories() {
27722
27853
  return this.categories[this.categories.length - 1];
27723
27854
  }
@@ -35144,7 +35275,7 @@ function getLastIndexNotNull(points4) {
35144
35275
  function getPointAtIndex(points4, idx) {
35145
35276
  return [points4[idx * 2], points4[idx * 2 + 1]];
35146
35277
  }
35147
- function getIndexRange(points4, xOrY, dim) {
35278
+ function getIndexRange2(points4, xOrY, dim) {
35148
35279
  const len2 = points4.length / 2;
35149
35280
  const dimIdx = dim === "x" ? 0 : 1;
35150
35281
  let a;
@@ -35678,7 +35809,7 @@ var LineView = class extends Chart_default {
35678
35809
  const distanceX = (isHorizontal ? distance2 : 0) * (isBaseInversed ? -1 : 1);
35679
35810
  const distanceY = (isHorizontal ? 0 : -distance2) * (isBaseInversed ? -1 : 1);
35680
35811
  const dim = isHorizontal ? "x" : "y";
35681
- const dataIndexRange = getIndexRange(points4, xOrY, dim);
35812
+ const dataIndexRange = getIndexRange2(points4, xOrY, dim);
35682
35813
  const indices = dataIndexRange.range;
35683
35814
  const diff = indices[1] - indices[0];
35684
35815
  let value;
@@ -56517,6 +56648,7 @@ var MineLinesSeriesModel2 = class extends Series_default {
56517
56648
  that.option.data.push(item);
56518
56649
  }
56519
56650
  });
56651
+ this.option.data = this.option.data.filter((item) => !item.isDelete);
56520
56652
  this.computedDataIndexById(this.option);
56521
56653
  return this.option.data;
56522
56654
  }
@@ -56750,6 +56882,7 @@ var LineFillsSeriesModel2 = class extends Series_default {
56750
56882
  that.option.data.push(item);
56751
56883
  }
56752
56884
  });
56885
+ this.option.data = this.option.data.filter((item) => !item.isDelete);
56753
56886
  this.computedDataIndexById(this.option);
56754
56887
  return this.option.data;
56755
56888
  }
@@ -57020,6 +57153,7 @@ var BoxesSeriesModel2 = class extends Series_default {
57020
57153
  that.option.data.push(item);
57021
57154
  }
57022
57155
  });
57156
+ this.option.data = this.option.data.filter((item) => !item.isDelete);
57023
57157
  this.computedDataIndexById(this.option);
57024
57158
  return this.option.data;
57025
57159
  }
@@ -58286,6 +58420,7 @@ var LabelsSeriesModel2 = class extends Series_default {
58286
58420
  that.option.data.push(item);
58287
58421
  }
58288
58422
  });
58423
+ this.option.data = this.option.data.filter((item) => !item.isDelete);
58289
58424
  this.computedDataIndexById(this.option);
58290
58425
  return this.option.data;
58291
58426
  }
@@ -63797,8 +63932,7 @@ var AxisPointerView2 = class extends Component_default2 {
63797
63932
  type: "updateAxisPointer",
63798
63933
  currTrigger,
63799
63934
  x,
63800
- y,
63801
- dataIndex: lastXIndex
63935
+ y
63802
63936
  });
63803
63937
  }
63804
63938
  };
@@ -64071,11 +64205,21 @@ function updateModelActually(showValueMap, axesInfo, outputPayload) {
64071
64205
  } else {
64072
64206
  !axisInfo.useHandle && (option.status = "hide");
64073
64207
  }
64074
- option.status === "show" && outputAxesInfo.push({
64075
- axisDim: axisInfo.axis.dim,
64076
- axisIndex: axisInfo.axis.model.componentIndex,
64077
- value: option.value
64078
- });
64208
+ if (option.status === "show") {
64209
+ const info = {
64210
+ axisDim: axisInfo.axis.dim,
64211
+ axisIndex: axisInfo.axis.model.componentIndex,
64212
+ value: option.value
64213
+ };
64214
+ if (axisInfo.axis.type === "category") {
64215
+ const scale4 = axisInfo.axis.scale;
64216
+ const ordinalMeta = scale4.getOrdinalMeta();
64217
+ const categories = ordinalMeta.getCategories();
64218
+ info.time = categories[info.value];
64219
+ info.interval = ordinalMeta.interval;
64220
+ }
64221
+ outputAxesInfo.push(info);
64222
+ }
64079
64223
  });
64080
64224
  }
64081
64225
  function dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction3) {
@@ -67270,8 +67414,12 @@ var each13 = each;
67270
67414
  var asc2 = asc;
67271
67415
  var leftMinVisibleBarCount = 2;
67272
67416
  var rightMinVisibleBarCount = 2;
67417
+ var triggerVisibleChanged = (api2, params) => {
67418
+ api2.trigger("visiblechanged", params);
67419
+ };
67273
67420
  var AxisProxy = class {
67274
67421
  constructor(dimName, axisIndex, dataZoomModel, ecModel) {
67422
+ this._throttleVisibleChanged = triggerVisibleChanged;
67275
67423
  this._dimName = dimName;
67276
67424
  this._axisIndex = axisIndex;
67277
67425
  this.ecModel = ecModel;
@@ -67382,6 +67530,8 @@ var AxisProxy = class {
67382
67530
  const rawExtentInfo = scale4.rawExtentInfo;
67383
67531
  const to = Math.round(lastBarRightSideDiffBarCount + dataCount + 0.5);
67384
67532
  const from = Math.round(to - barCount) - 1;
67533
+ const ordinalMeta = scale4.getOrdinalMeta();
67534
+ const categories = ordinalMeta.getCategories();
67385
67535
  this._valueWindow = [from, to];
67386
67536
  this._percentWindow = [barSpace, lastBarRightSideDiffBarCount, 0, 0];
67387
67537
  scale4.setSpace(barSpace, lastBarRightSideDiffBarCount);
@@ -67390,8 +67540,21 @@ var AxisProxy = class {
67390
67540
  rawExtentInfo.freeze();
67391
67541
  dataZoomModel.option.lastBarRightSideDiffBarCount = lastBarRightSideDiffBarCount;
67392
67542
  if (from < 0 && !dataZoomModel.isDragging) {
67393
- api2.trigger("loadmore");
67394
- }
67543
+ api2.trigger("loadmore", [from, to]);
67544
+ }
67545
+ const visibleFrom = Math.max(0, Math.ceil(to - barCount) - 1);
67546
+ const visibleTo = Math.min(to, dataCount - 1);
67547
+ const messageCenter = dataZoomModel.ecModel.scheduler.ecInstance.getMessageCenter();
67548
+ this._throttleVisibleChanged(messageCenter, {
67549
+ from,
67550
+ to,
67551
+ visibleFrom,
67552
+ visibleTo,
67553
+ fromTime: +categories[visibleFrom],
67554
+ toTime: +categories[visibleTo],
67555
+ offsetRightDistance: lastBarRightSideDiffBarCount > 0 ? lastBarRightSideDiffBarCount * barSpace : 0,
67556
+ offsetLeftDistance: from < 0 ? -from * barSpace : 0
67557
+ });
67395
67558
  } else {
67396
67559
  if (dataZoomModel.get("useValueRange") && (dataZoomModel.settledOption.startValue || dataZoomModel.settledOption.endValue)) {
67397
67560
  this._valueWindow = [
@@ -71026,7 +71189,7 @@ var TableModel2 = class extends Component_default {
71026
71189
  });
71027
71190
  this.option.tables = map(this.option.tables, function(table) {
71028
71191
  return newTableById[table.id] || table;
71029
- });
71192
+ }).filter((item) => !item.isDelete);
71030
71193
  }
71031
71194
  setAbleDataZoomUpdate(ableDataZoomUpdate) {
71032
71195
  this.ableDataZoomUpdate = ableDataZoomUpdate;
@@ -75037,7 +75200,7 @@ function createCoordSysRecord(api2, coordSysModel) {
75037
75200
  const axisProxy = dzInfo.model.findRepresentativeAxisProxy();
75038
75201
  const valueData = axisProxy.getDataValueWindow();
75039
75202
  if (axisProxy.getDimName() === "x" && valueData[0] < 0) {
75040
- api2.trigger("loadmore");
75203
+ api2.trigger("loadmore", valueData);
75041
75204
  }
75042
75205
  });
75043
75206
  api2.trigger("zoomend");