MCPcopy
hub / github.com/apache/echarts / createOrUpdateItem

Function createOrUpdateItem

src/chart/custom/CustomView.ts:963–995  ·  view source on GitHub ↗
(
    api: ExtensionAPI,
    existsEl: Element,
    dataIndex: number,
    elOption: CustomRootElementOption,
    seriesModel: CustomSeriesModel,
    group: ViewRootGroup,
    data: SeriesData<CustomSeriesModel>
)

Source from the content-addressed store, hash-verified

961}
962
963function createOrUpdateItem(
964 api: ExtensionAPI,
965 existsEl: Element,
966 dataIndex: number,
967 elOption: CustomRootElementOption,
968 seriesModel: CustomSeriesModel,
969 group: ViewRootGroup,
970 data: SeriesData<CustomSeriesModel>
971): Element {
972 // [Rule]
973 // If `renderItem` returns `null`/`undefined`/`false`, remove the previous el if existing.
974 // (It seems that violate the "merge" principle, but most of users probably intuitively
975 // regard "return;" as "show nothing element whatever", so make a exception to meet the
976 // most cases.)
977 // The rule or "merge" see [STRATEGY_MERGE].
978
979 // If `elOption` is `null`/`undefined`/`false` (when `renderItem` returns nothing).
980 if (!elOption) {
981 group.remove(existsEl);
982 return;
983 }
984 const el = doCreateOrUpdateEl(api, existsEl, dataIndex, elOption, seriesModel, group);
985 el && data.setItemGraphicEl(dataIndex, el);
986
987 el && toggleHoverEmphasis(
988 el,
989 elOption.focus,
990 elOption.blurScope,
991 elOption.emphasisDisabled
992 );
993
994 return el;
995}
996
997function doCreateOrUpdateEl(
998 api: ExtensionAPI,

Callers 2

renderMethod · 0.85
incrementalRenderMethod · 0.85

Calls 4

toggleHoverEmphasisFunction · 0.90
doCreateOrUpdateElFunction · 0.85
setItemGraphicElMethod · 0.80
removeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…