Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Tooltip in .700 for CartesianChart in WPF not working #859

Closed
andrew-baylis opened this issue Dec 29, 2022 · 2 comments
Closed

Custom Tooltip in .700 for CartesianChart in WPF not working #859

andrew-baylis opened this issue Dec 29, 2022 · 2 comments
Labels
priority 0 needs to be fixed asap.

Comments

@andrew-baylis
Copy link

Describe the bug
In WPF, the Cartesian Chart does not allow the setting of custom tooltips in the constructor or XML

To Reproduce
Use the code and approach suggested in your online documentation for beta 700

Expected behavior
The new tooltip class being used. Instead, the default tooltip is always used.

Desktop (please complete the following information):

  • OS: Windows 11

Additional context
I traced this behaviour to the InitializeCore method in CartesianChart.cs within LiveChartsCore.SkiaSharpView.WPF
This method is called in the OnApplyTempate of the chart (i.e. after the constructor) and it sets the tooltip to a new SKDefaultTooltip.
tooltip = new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;

I see that the legend is also created here, meaning that this cannot be overridden in the constructor either.

Moving the lines:

        legend = new SKDefaultLegend(); // Template.FindName("legend", this) as IChartLegend<SkiaSharpDrawingContext>;
        tooltip = new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;

to the constructor allows the Tooltip to be replaced in XML or the constructor as expected.

@andrew-baylis
Copy link
Author

Alternatively, we can leave the lines in the InitializeCore method, but check to see if they have already been assigned before overwriting them:

legend ??= new SKDefaultLegend(); // Template.FindName("legend", this) as IChartLegend<SkiaSharpDrawingContext>;
tooltip ??= new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;

maagy pushed a commit to maagy/LiveCharts2 that referenced this issue Apr 20, 2023
… user wouldn't be able to set custom tooltip. Just provide default value in constructor.
beto-rodriguez added a commit that referenced this issue May 22, 2023
#859 Do not override tooltip in InitializeCore method
@beto-rodriguez beto-rodriguez added the priority 0 needs to be fixed asap. label Jun 6, 2023
@beto-rodriguez
Copy link
Owner

This is already working in the latest release thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority 0 needs to be fixed asap.
Projects
None yet
Development

No branches or pull requests

2 participants