Pre loader

Failed to change the crosshairStroke and tooltipTextStroke later on

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

Answered
1
0

I tried to add a cursorModifier and then modify the stroke color later. But the color changes don’t work. Anything wrong with my codes?

Add cursorModified:

        let cursorModifier = new CursorModifier({
            crosshairStroke: #fff,
            crosshairStrokeThickness: 1,
            showTooltip: true,
            showAxisLabels: false,
            tooltipContainerBackground: "transparent",
            tooltipTextStroke: #fff,
        });
        sciChartSurfaceRef.chartModifiers.add(cursorModifier);

Change the stroke color:

        let cursorModifier = sciChartSurfaceRef.chartModifiers.get(0);
        if (cursorModifier) {
            cursorModifier.crosshairStroke = #333;
            cursorModifier.tooltipTextStroke = #333;
        }
Version
2.2.2415
  • You must to post comments
Best Answer
0
0

Hi Kelly,

at the moment these properties do not update the CursorModifier, the Crosshair stroke/strokeThickness and tooltip colors are set once when constructing the CursorModifier.

I have logged this as a bug in our internal issue tracker.

In the meantime, as a workaround we suggest to create a new CursorModifier with new properties and replace it, like this:

const cursorModifier = new CursorModifier({
    crosshairStroke: "#fff",
    crosshairStrokeThickness: 1,
    showTooltip: true,
    showAxisLabels: false,
    tooltipContainerBackground: "transparent",
    tooltipTextStroke: "#fff",
});
const sciChartSurface = new SciChartSurface(wasmContext);
sciChartSurface.chartModifiers.add(cursorModifier);

const cursorModifier2 = new CursorModifier({
    crosshairStroke = "#333",
    tooltipTextStroke = "333",
    crosshairStrokeThickness: 1,
    showTooltip: true,
    showAxisLabels: false,
    tooltipContainerBackground: "transparent",
});
sciChartSurface.chartModifiers.remove(cursorModifier);
sciChartSurface.chartModifiers.add(cursorModifier2);

Best regards,
Andrew

  • You must to post comments
0
0

Another workaround, you may also be able to force the cursor line/tooltip to be delteted & recreated with this code:

let cursorModifier = sciChartSurfaceRef.chartModifiers.get(0);
if (cursorModifier) {
    cursorModifier.crosshairStroke = #333;
    cursorModifier.tooltipTextStroke = #333;
    // untested. Force recreation of line and tootip 
    cursorModifier.onDetach();
    cursorModifier.onAttach();
}

In future we will fix the bug we reported so you won’t need to do this.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies