MCPcopy
hub / github.com/nhn/tui.chart / renderTooltip

Method renderTooltip

apps/chart/src/component/tooltip.ts:97–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95 }
96
97 renderTooltip() {
98 const model = this.getTooltipInfoModels().reduce<TooltipModel>(
99 (acc, item) => {
100 const { data, x, y, radius, width, height } = item;
101
102 acc.x = acc.x ? (acc.x + x) / 2 : x;
103 acc.y = acc.y ? (acc.y + y) / 2 : y;
104
105 if (isNumber(radius)) {
106 acc.target.radius = radius;
107 }
108
109 if (width) {
110 acc.target.width = width;
111 }
112
113 if (height) {
114 acc.target.height = height;
115 }
116
117 acc.data.push({
118 ...data,
119 value: Array.isArray(data.value)
120 ? (data.value as TooltipTitleValues).map((titleValue) => ({
121 ...titleValue,
122 formattedValue: this.getFormattedValue(titleValue.value, data),
123 }))
124 : data.value,
125 formattedValue: this.getFormattedValue(data.value, data),
126 });
127
128 if (!acc.category && data.category) {
129 acc.category = data.category;
130 }
131
132 if (data.templateType) {
133 acc.templateType = data.templateType;
134 }
135
136 return acc;
137 },
138 { type: 'tooltip', x: 0, y: 0, data: [], target: { radius: 0, width: 0, height: 0 } }
139 );
140
141 this.tooltipContainerEl.innerHTML = sanitizeHTML(
142 this.templateFunc(
143 model,
144 {
145 header: tooltipTemplates.defaultHeader(model, this.theme),
146 body: getBodyTemplate(model.templateType)(model, this.theme),
147 },
148 this.theme
149 )
150 );
151 this.setTooltipPosition(model);
152 }
153
154 initialize({ chartEl }) {

Callers 1

TooltipClass · 0.95

Calls 6

getTooltipInfoModelsMethod · 0.95
getFormattedValueMethod · 0.95
setTooltipPositionMethod · 0.95
isNumberFunction · 0.90
sanitizeHTMLFunction · 0.90
getBodyTemplateFunction · 0.90

Tested by

no test coverage detected