Pre loader

Styling the Tooltip

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I am trying to modify the tooltip with the following code:

 function tooltipTemplate(
    id: string,
    seriesInfo: SeriesInfo,
    rolloverTooltip: RolloverTooltipSvgAnnotation
  ) {
    console.log({
      id,
      seriesInfo,
      rolloverTooltip,
    });
    return `<svg width="120" height="16">
    <rect x="0" y="0" width="100%" height="100%" fill="${seriesInfo.stroke}"/>
    <svg width="100%">
        <text y="0" x="0" font-size="12" font-family="Verdana" dy="0" fill="white">
            <tspan x="4" dy="1em">${seriesInfo.seriesName}: ${seriesInfo.formattedYValue}</tspan>
        </text>
    </svg>
</svg>`;
  }

It is working but now all the tooltip are on top of each other, how can I fix that?

Version
3.4.644
Images
  • Jhonatan Laguna
    Is there a way to solve this?
  • Jhonatan Laguna
    This is for Rollover, no errors in console. the function works just fine, I just need a way to avoid the overlapping
  • You must to post comments
0
0

Hi Jhonatan,

When overriding RenderableSeries.rolloverModifierProps.tooltipTemplate, you will need to specify the size of the new tooltip so that SciChart.js can perform layout and stop them from overlapping.

Try this code instead:

  const tooltipTemplate = (id, seriesInfo, rolloverTooltip) => {
  rolloverTooltip.updateSize(120, 16); // This line is needed
  return `<svg width="120" height="16">
    <rect x="0" y="0" width="100%" height="100%" fill="${seriesInfo.stroke}"/>
    <svg width="100%">
      <text y="0" x="0" font-size="12" font-family="Verdana" dy="0" fill="white">
        <tspan x="4" dy="1em">${seriesInfo.seriesName}: ${seriesInfo.formattedYValue}</tspan>
      </text>
    </svg>
  </svg>`
  };

  // Add a tooltipTemplate to this series to override the tooltip
  lineSeries0.rolloverModifierProps.tooltipTemplate = tooltipTemplate;
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.