tvcharts 0.6.21 → 0.6.23

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
@@ -11886,18 +11886,26 @@ function getAllSelectedIndices(ecModel) {
11886
11886
  }
11887
11887
  function getSeriesPointData(ecModel, payload = {}) {
11888
11888
  const seriesPointData = {};
11889
+ const {dataIndex, rawDataIndex} = payload;
11889
11890
  ecModel.eachSeries(function(seriesModel) {
11890
11891
  if (seriesModel.get("statusLineInvisible")) {
11891
11892
  return;
11892
11893
  }
11893
11894
  const formatter = seriesModel.get("formatter");
11895
+ const offset = seriesModel.get("offset") ?? 0;
11896
+ const showLast = seriesModel.get("showLast") ?? 0;
11894
11897
  const data = seriesModel.getData();
11895
- const isRaw = !payload.dataIndex;
11896
- const index = payload.dataIndex ?? data.count(isRaw) - 1;
11897
- const values = isRaw ? data.getValuesByRawIndex(index) : data.getValues(index);
11898
- let color2 = data.getItemVisual(index, "style").fill;
11898
+ let isRaw = !dataIndex;
11899
+ const lastIndex = data.count(true) - 1;
11900
+ let index = dataIndex ? dataIndex - offset : rawDataIndex ? rawDataIndex - offset : lastIndex;
11901
+ if (showLast && (isRaw ? index : data.getRawIndex(index)) <= lastIndex - showLast) {
11902
+ index = lastIndex;
11903
+ isRaw = true;
11904
+ }
11905
+ index = Math.min(lastIndex, index);
11906
+ let values = isRaw ? data.getValuesByRawIndex(index) : data.getValues(index);
11907
+ let color2 = data.getItemVisual(index, "style")?.fill;
11899
11908
  const isCandlesStick = seriesModel.subType === "candlestick";
11900
- const isLinesPlot = seriesModel.subType === "linesPlot";
11901
11909
  const dim = seriesModel.subType === "candlestick" ? "close" : "y";
11902
11910
  const fnKey = isRaw ? "getByRawIndex" : "get";
11903
11911
  if (isCandlesStick) {
@@ -11909,9 +11917,13 @@ function getSeriesPointData(ecModel, payload = {}) {
11909
11917
  if (fill) {
11910
11918
  color2 = fill;
11911
11919
  }
11912
- } else if (isLinesPlot) {
11920
+ } else if (["linesPlot", "labels"].includes(seriesModel.subType)) {
11921
+ const isLinesPlot = seriesModel.subType === "linesPlot";
11913
11922
  const dataItem = data.getItemModel(index, isRaw);
11914
- const fill = dataItem.get(["lineStyle", "color"]);
11923
+ const fill = dataItem.get([isLinesPlot ? "lineStyle" : "itemStyle", "color"]);
11924
+ if (!isLinesPlot) {
11925
+ values = [index, dataItem.get("showValue")];
11926
+ }
11915
11927
  if (fill) {
11916
11928
  color2 = fill;
11917
11929
  }
@@ -11934,12 +11946,13 @@ function getSeriesPointData(ecModel, payload = {}) {
11934
11946
  seriesPointData[seriesName] = {
11935
11947
  name: seriesName,
11936
11948
  data: values.map((item, index2) => {
11937
- return formatter && index2 !== 0 ? formatter(item) : item;
11949
+ return formatter && index2 !== 0 && item ? formatter(item) : item;
11938
11950
  }),
11939
11951
  color: color2,
11940
11952
  seriesId,
11941
11953
  changePercent,
11942
- diffValue
11954
+ diffValue,
11955
+ type: seriesModel.subType
11943
11956
  };
11944
11957
  });
11945
11958
  return seriesPointData;
@@ -17728,6 +17741,9 @@ var DefaultDataProvider2 = class {
17728
17741
  }
17729
17742
  appendData(newData) {
17730
17743
  }
17744
+ updateData(newData) {
17745
+ return {update: 0, append: 0};
17746
+ }
17731
17747
  clean() {
17732
17748
  }
17733
17749
  };
@@ -17795,7 +17811,8 @@ DefaultDataProvider.internalField = function() {
17795
17811
  providerMethods = {
17796
17812
  [SOURCE_FORMAT_ARRAY_ROWS + "_" + SERIES_LAYOUT_BY_COLUMN]: {
17797
17813
  pure: true,
17798
- appendData: appendDataSimply
17814
+ appendData: appendDataSimply,
17815
+ updateData: updateDataSimply
17799
17816
  },
17800
17817
  [SOURCE_FORMAT_ARRAY_ROWS + "_" + SERIES_LAYOUT_BY_ROW]: {
17801
17818
  pure: true,
@@ -17805,7 +17822,8 @@ DefaultDataProvider.internalField = function() {
17805
17822
  },
17806
17823
  [SOURCE_FORMAT_OBJECT_ROWS]: {
17807
17824
  pure: true,
17808
- appendData: appendDataSimply
17825
+ appendData: appendDataSimply,
17826
+ updateData: updateDataSimply
17809
17827
  },
17810
17828
  [SOURCE_FORMAT_KEYED_COLUMNS]: {
17811
17829
  pure: true,
@@ -17820,7 +17838,8 @@ DefaultDataProvider.internalField = function() {
17820
17838
  }
17821
17839
  },
17822
17840
  [SOURCE_FORMAT_ORIGINAL]: {
17823
- appendData: appendDataSimply
17841
+ appendData: appendDataSimply,
17842
+ updateData: updateDataSimply
17824
17843
  },
17825
17844
  [SOURCE_FORMAT_TYPED_ARRAY]: {
17826
17845
  persistent: false,
@@ -17842,6 +17861,30 @@ DefaultDataProvider.internalField = function() {
17842
17861
  this._data.push(newData[i]);
17843
17862
  }
17844
17863
  }
17864
+ function updateDataSimply(newData) {
17865
+ const data = this._data;
17866
+ let lastIndex = data.length - 1;
17867
+ for (let i = 0; i < newData.length; i++) {
17868
+ const ele = newData[i];
17869
+ if (Array.isArray(ele)) {
17870
+ if (ele[0] === data[lastIndex][0]) {
17871
+ data[lastIndex] = ele;
17872
+ lastIndex++;
17873
+ continue;
17874
+ }
17875
+ } else if (typeof ele === "object" && Array.isArray(ele.value) && ele.value[0] == data[lastIndex][0]) {
17876
+ data[lastIndex] = ele;
17877
+ lastIndex++;
17878
+ continue;
17879
+ }
17880
+ data.push(newData[i]);
17881
+ }
17882
+ const update = lastIndex - data.length - 1;
17883
+ return {
17884
+ update,
17885
+ append: newData.length - update
17886
+ };
17887
+ }
17845
17888
  }();
17846
17889
  var getItemSimply = function(rawData, startIndex, dimsDef, idx) {
17847
17890
  return rawData[idx];
@@ -18776,6 +18819,23 @@ var DataStore2 = class {
18776
18819
  }
18777
18820
  return [start2, end2];
18778
18821
  }
18822
+ updateData(data) {
18823
+ if (true) {
18824
+ assert(!this._indices, "appendData can only be called on raw data.");
18825
+ }
18826
+ const provider = this._provider;
18827
+ let start2 = this.count();
18828
+ const {update} = provider.updateData(data);
18829
+ let end2 = provider.count();
18830
+ start2 = start2 - update;
18831
+ if (!provider.persistent) {
18832
+ end2 += start2;
18833
+ }
18834
+ if (start2 < end2) {
18835
+ this._initDataFromProvider(start2, end2, true);
18836
+ }
18837
+ return [start2, end2];
18838
+ }
18779
18839
  appendValues(values, minFillLen) {
18780
18840
  const chunks = this._chunks;
18781
18841
  const dimensions = this._dimensions;
@@ -20001,10 +20061,14 @@ var SeriesModel2 = class extends Component_default {
20001
20061
  const data = this.getRawData();
20002
20062
  data.appendData(params.data);
20003
20063
  }
20004
- updateData(params) {
20064
+ updateValue(params) {
20005
20065
  const data = this.getRawData();
20006
20066
  data.updateValue(params.data[0]);
20007
20067
  }
20068
+ updateData(params) {
20069
+ const data = this.getRawData();
20070
+ data.appendData(params.data);
20071
+ }
20008
20072
  getData(dataType) {
20009
20073
  const task = getCurrentTask(this);
20010
20074
  if (task) {
@@ -23510,7 +23574,7 @@ var enableConnect;
23510
23574
  var markStatusToUpdate;
23511
23575
  var applyChangedStates;
23512
23576
  var triggerSelectItem = ({messageCenter, ecModel, type, eventObj = {}}) => {
23513
- const data = getSeriesPointData(ecModel, {dataIndex: eventObj.dataIndexInside});
23577
+ const data = getSeriesPointData(ecModel, {dataIndex: eventObj.dataIndexInside, rawDataIndex: eventObj.dataIndex});
23514
23578
  messageCenter.trigger("selectitem", {
23515
23579
  data,
23516
23580
  dataIndex: eventObj.dataIndex,
@@ -23520,7 +23584,7 @@ var triggerSelectItem = ({messageCenter, ecModel, type, eventObj = {}}) => {
23520
23584
  var ECharts = class extends Eventful_default {
23521
23585
  constructor(dom, theme2, opts) {
23522
23586
  super(new ECEventProcessor());
23523
- this._throttledSelectItem = throttle(triggerSelectItem, 60);
23587
+ this._throttledSelectItem = throttle(triggerSelectItem, 80);
23524
23588
  this._chartsViews = [];
23525
23589
  this._chartsMap = {};
23526
23590
  this._componentsViews = [];
@@ -24237,7 +24301,7 @@ var ECharts = class extends Eventful_default {
24237
24301
  this._scheduler.unfinished = true;
24238
24302
  this.getZr().wakeUp();
24239
24303
  }
24240
- updateData(batch) {
24304
+ updateData(batch, silent = false) {
24241
24305
  if (this._disposed) {
24242
24306
  disposedWarning(this.id);
24243
24307
  return;
@@ -24245,28 +24309,45 @@ var ECharts = class extends Eventful_default {
24245
24309
  let firstSeriesModel = void 0;
24246
24310
  let isUpdateData = false;
24247
24311
  each(batch, (params, index) => {
24312
+ const ecModel = this.getModel();
24248
24313
  const seriesIndex = params.seriesIndex;
24249
24314
  const seriesName = params.seriesName;
24250
- const ecModel = this.getModel();
24315
+ if (params.type === "component") {
24316
+ const tableModal = ecModel.findComponents({mainType: "table"})[0];
24317
+ console.log("%c [ tableModal ]-1621", "font-size:13px; background:pink; color:#bf2c9f;", tableModal);
24318
+ return;
24319
+ }
24251
24320
  const seriesModel = seriesIndex !== void 0 ? ecModel.getSeriesByIndex(seriesIndex) : ecModel.getSeriesByName(seriesName)[0];
24252
24321
  if (true) {
24253
24322
  assert(params.data && seriesModel);
24254
24323
  }
24255
24324
  const seriesData = seriesModel.getData();
24256
24325
  const lastIndex = seriesData.count(true) - 1;
24257
- const paramId = params.data[0][0];
24258
24326
  const scale5 = seriesModel.coordinateSystem.getBaseAxis().scale;
24259
24327
  const ordinalMeta = scale5.getOrdinalMeta();
24260
- const id = ordinalMeta.getLastCategories();
24261
- const isUpdate = params.operation !== void 0 ? params.operation === "update" : id == paramId;
24328
+ const isUpdate = params.operation === "update";
24262
24329
  if (isUpdate) {
24263
- seriesModel.updateData({data: map(params.data, (item, index2) => {
24330
+ seriesModel.updateValue({data: map(params.data, (item, index2) => {
24264
24331
  const idx = lastIndex + index2;
24265
24332
  seriesModel.option.data[idx] = item.slice(1);
24266
24333
  item[0] = idx;
24267
24334
  return item;
24268
24335
  })});
24269
24336
  isUpdateData = true;
24337
+ } else if (params.operation === "script") {
24338
+ const categories = [];
24339
+ const data = map(params.data, (item, index2) => {
24340
+ const idx = lastIndex + index2;
24341
+ seriesModel.option.data[idx] = item;
24342
+ if (idx > lastIndex) {
24343
+ categories.push(item.value[0]);
24344
+ }
24345
+ return item;
24346
+ });
24347
+ if (params.isMainSeries && data.length > 1) {
24348
+ ordinalMeta.appendData(categories);
24349
+ }
24350
+ seriesModel.updateData({data});
24270
24351
  } else {
24271
24352
  const categories = [];
24272
24353
  const formatData = map(params.data, (item) => {
@@ -24285,13 +24366,17 @@ var ECharts = class extends Eventful_default {
24285
24366
  firstSeriesModel = seriesModel;
24286
24367
  }
24287
24368
  });
24369
+ if (!firstSeriesModel) {
24370
+ return;
24371
+ }
24288
24372
  const coordSys = firstSeriesModel.coordinateSystem;
24289
24373
  const baseAxis = coordSys.getBaseAxis();
24290
24374
  const scale4 = baseAxis.scale;
24375
+ const isMove = !isUpdateData && scale4.lastBarRightSideDiffBarCount < 1.5;
24291
24376
  const payload = {
24292
24377
  type: "dataZoom",
24293
24378
  barSpace: scale4.barSpace,
24294
- lastBarRightSideDiffBarCount: !isUpdateData && scale4.lastBarRightSideDiffBarCount < 1.5 ? scale4.lastBarRightSideDiffBarCount - 1 : scale4.lastBarRightSideDiffBarCount
24379
+ lastBarRightSideDiffBarCount: isMove ? scale4.lastBarRightSideDiffBarCount - 1 : scale4.lastBarRightSideDiffBarCount
24295
24380
  };
24296
24381
  doDispatchAction.call(this, payload, true);
24297
24382
  }
@@ -24311,7 +24396,7 @@ var ECharts = class extends Eventful_default {
24311
24396
  barSpace: scale4.barSpace,
24312
24397
  lastBarRightSideDiffBarCount: scale4.lastBarRightSideDiffBarCount < 1.5 ? scale4.lastBarRightSideDiffBarCount - 1 : scale4.lastBarRightSideDiffBarCount
24313
24398
  };
24314
- doDispatchAction.call(this, payload, true);
24399
+ doDispatchAction.call(this, payload, false);
24315
24400
  }
24316
24401
  }
24317
24402
  };
@@ -24841,9 +24926,11 @@ ECharts.internalField = function() {
24841
24926
  updateStates(seriesModel, chartView);
24842
24927
  });
24843
24928
  updateHoverLayerStatus(ecIns, ecModel);
24844
- const data = getSeriesPointData(ecModel);
24845
- const messageCenter = ecIns._messageCenter;
24846
- messageCenter.trigger("selectitem", {data, type: "series"});
24929
+ ecIns._throttledSelectItem({
24930
+ messageCenter: ecIns._messageCenter,
24931
+ ecModel,
24932
+ type: "series"
24933
+ });
24847
24934
  lifecycle_default.trigger("series:afterupdate", ecModel, api2, updateParams);
24848
24935
  };
24849
24936
  markStatusToUpdate = function(ecIns) {
@@ -25987,6 +26074,10 @@ var SeriesData2 = class {
25987
26074
  const range = this._store.appendData(data);
25988
26075
  this._doInit(range[0], range[1]);
25989
26076
  }
26077
+ updateData(data) {
26078
+ const range = this._store.updateData(data);
26079
+ this._doInit(range[0], range[1]);
26080
+ }
25990
26081
  updateValue(value) {
25991
26082
  this._store.updateValue(value);
25992
26083
  }
@@ -55073,13 +55164,12 @@ var linesPlotLayout = {
55073
55164
  const xOffset = seriesModel.get("offset") || 0;
55074
55165
  const symbolVisible = seriesModel.get("symbolVisible");
55075
55166
  const symbolSize = seriesModel.get("symbolSize");
55076
- const globalSymbol = seriesModel.get("symbol");
55167
+ const showLast = seriesModel.get("showLast");
55077
55168
  return {
55078
55169
  progress(params, lineData) {
55079
55170
  const linePointsByKey = {};
55080
55171
  const symbolPointsByColor = {};
55081
55172
  let lastKey = "";
55082
- let offset = 0;
55083
55173
  const stroke = seriesModel.getLineStyle().stroke;
55084
55174
  const defaultColor = Array.isArray(stroke) ? stroke[0] : stroke;
55085
55175
  function setSymbolPoint(point, index) {
@@ -55088,6 +55178,7 @@ var linesPlotLayout = {
55088
55178
  }
55089
55179
  const dataModal = lineData.getItemModel(index);
55090
55180
  const symbolColor = dataModal.get("itemStyle")?.color;
55181
+ console.log("%c [ dataModal ]-94", "font-size:13px; background:pink; color:#bf2c9f;", dataModal);
55091
55182
  const symbol = dataModal.get("symbol");
55092
55183
  const symbolKey = `${symbol}`;
55093
55184
  const symbolData = symbolPointsByColor[symbolKey] || [];
@@ -55098,8 +55189,12 @@ var linesPlotLayout = {
55098
55189
  });
55099
55190
  symbolPointsByColor[symbolKey] = symbolData;
55100
55191
  }
55192
+ const lastIndex = data.count(true) - 1;
55101
55193
  for (let i = params.start; i < params.end; i++) {
55102
- const isRawLast = i + 1 === params.end ? data.getRawIndex(i) === data.count(true) - 1 : false;
55194
+ if (showLast && lastIndex - data.getRawIndex(i) >= showLast) {
55195
+ continue;
55196
+ }
55197
+ const isRawLast = i + 1 === params.end ? data.getRawIndex(i) === lastIndex : false;
55103
55198
  const isRawFirst = i === 0 ? data.getRawIndex(i) === 0 : false;
55104
55199
  const x = store.get(dimIdx0, i);
55105
55200
  const y = store.get(dimIdx1, i);
@@ -55112,7 +55207,7 @@ var linesPlotLayout = {
55112
55207
  }
55113
55208
  let nextPoint = [];
55114
55209
  if (!isSingle && isRawLast) {
55115
- const lastPoints = linePointsByKey[lastKey];
55210
+ const lastPoints = linePointsByKey[lastKey] || [];
55116
55211
  lastPoints.push(point);
55117
55212
  break;
55118
55213
  }
@@ -55479,6 +55574,7 @@ var LabelsVisual = {
55479
55574
  const bandWidth = Math.max(1, Math.round(seriesModel.coordinateSystem.getAxesByScale("ordinal")[0].scale.barSpace * 0.8));
55480
55575
  const data = seriesModel.getData();
55481
55576
  const location = seriesModel.get("location");
55577
+ const showLast = seriesModel.get("showLast");
55482
55578
  const symbolOptions = {};
55483
55579
  for (let i = 0; i < SYMBOL_PROPS_WITH_CB2.length; i++) {
55484
55580
  const symbolPropName = SYMBOL_PROPS_WITH_CB2[i];
@@ -55489,7 +55585,11 @@ var LabelsVisual = {
55489
55585
  data.setVisual(extend({
55490
55586
  symbolKeepAspect: seriesModel.get("symbolKeepAspect")
55491
55587
  }, symbolOptions));
55588
+ const lastIndex = data.count(true) - 1;
55492
55589
  function dataEach(data2, idx) {
55590
+ if (showLast && lastIndex - data2.getRawIndex(idx) >= showLast) {
55591
+ return;
55592
+ }
55493
55593
  const itemModel = data2.getItemModel(idx);
55494
55594
  let symbol = itemModel.getShallow("symbol");
55495
55595
  let symbolSize = itemModel.getShallow("symbolSize");
@@ -55582,11 +55682,16 @@ var labelsLayout = {
55582
55682
  const dimIdx1 = data.getDimensionIndex(dims[1]);
55583
55683
  const xOffset = seriesModel.get("offset") || 0;
55584
55684
  const price = getYByLocation(seriesModel);
55685
+ const showLast = seriesModel.get("showLast");
55585
55686
  return {
55586
55687
  progress(params, labelsData) {
55587
55688
  const tmpIn = [];
55588
55689
  const tmpOut = [];
55690
+ const lastIndex = data.count(true) - 1;
55589
55691
  for (let i = params.start; i < params.end; i++) {
55692
+ if (showLast && lastIndex - data.getRawIndex(i) >= showLast) {
55693
+ continue;
55694
+ }
55590
55695
  tmpIn[0] = store.get(dimIdx0, i) + xOffset;
55591
55696
  tmpIn[1] = store.get(dimIdx1, i);
55592
55697
  const point = coordSys.dataToPoint(tmpIn, null, tmpOut);
@@ -55921,6 +56026,7 @@ var fillsLayout = {
55921
56026
  const data = seriesModel.getData();
55922
56027
  const fillgaps = seriesModel.get("fillgaps");
55923
56028
  const isMonoHline = seriesModel.get("isMonoHline");
56029
+ const showLast = seriesModel.get("showLast");
55924
56030
  const dimIdx0 = 0;
55925
56031
  const dimIdP1 = 1;
55926
56032
  const dimIdP2 = 2;
@@ -55948,7 +56054,11 @@ var fillsLayout = {
55948
56054
  let lastKey = "";
55949
56055
  let plot1Points = [];
55950
56056
  let plot2Points = [];
56057
+ const lastIndex = fillsData.count(true) - 1;
55951
56058
  for (let i = params.start; i < params.end; i++) {
56059
+ if (showLast && lastIndex - fillsData.getRawIndex(i) >= showLast) {
56060
+ continue;
56061
+ }
55952
56062
  const last = i + 1 === params.end;
55953
56063
  const get2 = last ? "getByRawIndex" : "get";
55954
56064
  const index = last ? fillsData.getRawIndex(i) : i;
@@ -56176,13 +56286,18 @@ var bgColorLayout = {
56176
56286
  const store = data.getStore();
56177
56287
  const dimIdx0 = data.getDimensionIndex(dims[0]);
56178
56288
  const xOffset = seriesModel.get("offset") || 0;
56289
+ const showLast = seriesModel.get("showLast");
56179
56290
  return {
56180
56291
  progress(params, bgColorData) {
56181
56292
  const rectsByColor = {};
56182
56293
  const width = Math.ceil(coordSys.getBaseAxis().scale.barSpace) || 5;
56183
56294
  const leftOffset = width / 2;
56184
56295
  const {height, startY} = getHeight(seriesModel);
56296
+ const lastIndex = bgColorData.count(true) - 1;
56185
56297
  for (let i = params.start; i < params.end; i++) {
56298
+ if (showLast && lastIndex - bgColorData.getRawIndex(i) >= showLast) {
56299
+ continue;
56300
+ }
56186
56301
  const itemModel = bgColorData.getItemModel(i);
56187
56302
  const {color: color2} = itemModel.get("itemStyle");
56188
56303
  if (!color2) {