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

Function formatTooltipArrayValue

src/component/tooltip/seriesFormatTooltip.ts:103–155  ·  view source on GitHub ↗
(
    value: unknown[],
    series: SeriesModel,
    dataIndex: number,
    tooltipDims: DimensionName[],
    colorStr: ColorString
)

Source from the content-addressed store, hash-verified

101}
102
103function formatTooltipArrayValue(
104 value: unknown[],
105 series: SeriesModel,
106 dataIndex: number,
107 tooltipDims: DimensionName[],
108 colorStr: ColorString
109): {
110 inlineValues: unknown[];
111 inlineValueTypes: DimensionType[];
112 blocks: TooltipMarkupBlockFragment[];
113} {
114 // check: category-no-encode-has-axis-data in dataset.html
115 const data = series.getData();
116 const isValueMultipleLine = reduce(value, function (isValueMultipleLine, val, idx) {
117 const dimItem = data.getDimensionInfo(idx);
118 return isValueMultipleLine = isValueMultipleLine
119 || (dimItem && dimItem.tooltip !== false && dimItem.displayName != null);
120 }, false);
121
122 const inlineValues: unknown[] = [];
123 const inlineValueTypes: DimensionType[] = [];
124 const blocks: TooltipMarkupBlockFragment[] = [];
125
126 tooltipDims.length
127 ? each(tooltipDims, function (dim) {
128 setEachItem(retrieveRawValue(data, dataIndex, dim), dim);
129 })
130 // By default, all dims is used on tooltip.
131 : each(value, setEachItem);
132
133 function setEachItem(val: unknown, dim: DimensionName | number): void {
134 const dimInfo = data.getDimensionInfo(dim);
135 // If `dimInfo.tooltip` is not set, show tooltip.
136 if (!dimInfo || dimInfo.otherDims.tooltip === false) {
137 return;
138 }
139 if (isValueMultipleLine) {
140 blocks.push(createTooltipMarkup('nameValue', {
141 markerType: 'subItem',
142 markerColor: colorStr,
143 name: dimInfo.displayName,
144 value: val,
145 valueType: dimInfo.type
146 }));
147 }
148 else {
149 inlineValues.push(val);
150 inlineValueTypes.push(dimInfo.type);
151 }
152 }
153
154 return { inlineValues, inlineValueTypes, blocks };
155}

Callers 1

Calls 5

retrieveRawValueFunction · 0.90
setEachItemFunction · 0.85
getDataMethod · 0.65
eachFunction · 0.50
getDimensionInfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…