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;
}
- Kelly Chan asked 1 year ago
- last edited 1 year ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
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.
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
Please login first to submit.