Skip to content

Commit df9dc3b

Browse files
committed
fix #4868; reflect marker shapes in tooltip
1 parent 02fc434 commit df9dc3b

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

src/assets/apexcharts.css

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,74 @@ rect.legend-mouseover-inactive,
149149
}
150150

151151
.apexcharts-tooltip-marker {
152-
width: 12px;
153-
height: 12px;
152+
display: inline-block;
154153
position: relative;
155-
top: 0;
156-
margin-right: 10px;
157-
border-radius: 50%
154+
width: 16px;
155+
height: 16px;
156+
font-size: 16px;
157+
line-height: 16px;
158+
margin-right: 4px;
159+
text-align: center;
160+
vertical-align: middle;
161+
color: inherit;
162+
}
163+
164+
.apexcharts-tooltip-marker::before {
165+
content: "";
166+
display: inline-block;
167+
width: 100%;
168+
text-align: center;
169+
color: currentcolor;
170+
text-rendering: optimizeLegibility;
171+
-webkit-font-smoothing: antialiased;
172+
font-size: 26px;
173+
line-height: 14px;
174+
font-weight: 900;
175+
}
176+
177+
.apexcharts-tooltip-marker[shape="circle"]::before {
178+
content: "\25CF";
179+
}
180+
181+
.apexcharts-tooltip-marker[shape="square"]::before,
182+
.apexcharts-tooltip-marker[shape="rect"]::before {
183+
content: "\25A0";
184+
transform: translate(-1px, -2px);
185+
}
186+
187+
.apexcharts-tooltip-marker[shape="line"]::before {
188+
content: "\2500";
189+
}
190+
191+
.apexcharts-tooltip-marker[shape="diamond"]::before {
192+
content: "\25C6";
193+
font-size: 28px;
194+
}
195+
196+
.apexcharts-tooltip-marker[shape="triangle"]::before {
197+
content: "\25B2";
198+
font-size: 22px;
199+
}
200+
201+
.apexcharts-tooltip-marker[shape="cross"]::before {
202+
content: "\2715";
203+
font-size: 18px;
204+
}
205+
206+
.apexcharts-tooltip-marker[shape="plus"]::before {
207+
content: "\2715";
208+
transform: rotate(45deg) translate(-1px, -1px);
209+
font-size: 18px;
210+
}
211+
212+
.apexcharts-tooltip-marker[shape="star"]::before {
213+
content: "\2605";
214+
font-size: 18px;
215+
}
216+
217+
.apexcharts-tooltip-marker[shape="sparkle"]::before {
218+
content: "\2726";
219+
font-size: 20px;
158220
}
159221

160222
.apexcharts-tooltip-series-group {

src/modules/tooltip/Labels.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export default class Labels {
268268
ttItemsChildren = ttItems[t].children
269269

270270
if (w.config.tooltip.fillSeriesColor) {
271-
ttItems[t].style.backgroundColor = pColor
271+
ttItems[t].style.color = pColor
272272
ttItemsChildren[0].style.display = 'none'
273273
}
274274

@@ -309,7 +309,7 @@ export default class Labels {
309309
pColor = w.config.tooltip.marker.fillColors[t]
310310
}
311311

312-
ttItemsChildren[0].style.backgroundColor = pColor
312+
ttItemsChildren[0].style.color = pColor
313313
}
314314

315315
if (!w.config.tooltip.marker.show) {
@@ -325,7 +325,7 @@ export default class Labels {
325325

326326
if (goalVals.length && w.globals.seriesGoals[t]) {
327327
const createGoalsHtml = () => {
328-
let gLabels = '<div >'
328+
let gLabels = '<div>'
329329
let gVals = '<div>'
330330
goalVals.forEach((goal, gi) => {
331331
gLabels += ` <div style="display: flex"><span class="apexcharts-tooltip-marker" style="background-color: ${goal.attrs.strokeColor}; height: 3px; border-radius: 0; top: 5px;"></span> ${goal.attrs.name}</div>`

src/modules/tooltip/Tooltip.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,17 @@ export default class Tooltip {
147147

148148
let point = document.createElement('span')
149149
point.classList.add('apexcharts-tooltip-marker')
150-
point.style.backgroundColor = w.globals.colors[i]
150+
point.style.color = w.globals.colors[i]
151+
152+
console.log(w.globals.colors)
153+
154+
let mShape = w.config.markers.shape
155+
let shape = mShape
156+
if (Array.isArray(mShape)) {
157+
shape = mShape[i]
158+
}
159+
160+
point.setAttribute('shape', shape)
151161
gTxt.appendChild(point)
152162

153163
const gYZ = document.createElement('div')

0 commit comments

Comments
 (0)