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

WinForm - Legend and tooltip goes out of bound/getting cut off on the edge #987

Closed
dh4618 opened this issue Apr 25, 2023 · 2 comments
Closed
Labels
bug Something isn't working priority 0 needs to be fixed asap.

Comments

@dh4618
Copy link

dh4618 commented Apr 25, 2023

Describe the bug
When there are multiple series being added to the chart, the legend and tool tip get cut off on the edge.

i.e.:
image

Additionally, when legend is put on the side, for example, LegendPosition = Left in this case, while hovering over the right most points the tooltip doesn't show up.
image

To Reproduce

var seriesCollection = new ISeries[]
{
new LineSeries<int>
{
Values = new []{ 2, 5, 10, 6, 0 },
Name = "Test 1",

},
new LineSeries<int>
{
Values = new []{ 3, 17, 2, 9, 14 },
Name = "Test 2",

},
new LineSeries<int>
{
Values = new []{ 2, 15, 4, 2, 6 },
Name = "Test 3"
},
new LineSeries<int>
{
Values = new []{ 3, 7, 12, 9, 4 },
Name = "Test 4"
},
new LineSeries<int>
{
Values = new []{ 2, 15, 4, 2, 24 },
Name = "Test 5"
},
new LineSeries<int>
{
Values = new []{ 3, 7, 2, 9, 19 },
Name = "Test 6"
},
new LineSeries<int>
{
Values = new []{ 3, 5, 5, 8, 6 },
Name = "Test 7"
},
new LineSeries<int>
{
Values = new []{ 3, 7, 2, 9, 4 },
Name = "Test 8"
}
};

chartDemo.Series = seriesCollection;
chartDemo.LegendPosition = LiveChartsCore.Measure.LegendPosition.Bottom;

Expected behavior
Legends wrapped in multiple lines, and tooltip able to float outside of the chart container. (Like the old livecharts!)

Screenshots
See above.

Desktop (please complete the following information):

  • OS: Windows 10 Pro 21H2
  • Visual Studio 2022 .Net6.0
@Vasil20Angelov
Copy link

Also the same problem for WPF

@manokara
Copy link

manokara commented May 2, 2023

This is known issue (at least the legend clipping part, see #832) and I think actually affects almost all backends because it's down to the layouting of each backend not taking wrapping into account. In the Skia backend, which is what I'm using, the layout in done in a StackPanel that is used as both a container for the legends and the legends themselves. There isn't really a workaround other than changing position, but eventually you're also going to run out of vertical space if you have many datasets. The layouting process uses internal classes and variables so the only way to fix this is by forking the repo, which I did.

So here's the patch for fixing the (horizontal) wrapping issue in the Skia backend: gist. I looked into it and on WinForms DefaultLegend also does manual layouting like in Skia, so you should be able to reuse this logic there. Mind you that WeirdOffset is something particular to the Skia backend.

@beto-rodriguez beto-rodriguez added bug Something isn't working priority 0 needs to be fixed asap. labels Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority 0 needs to be fixed asap.
Projects
None yet
Development

No branches or pull requests

4 participants