Skip to content

Commit

Permalink
fixed separators key issue
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Aug 27, 2022
1 parent 6782fe6 commit 885be37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 6 additions & 4 deletions samples/WinUISample/WinUISample/Axes/Style/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
</UserControl.DataContext>
<Grid Background="#333333">
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}"
TooltipPosition="Hidden"
ZoomMode="Both">
</lvc:CartesianChart>
</Grid>
</UserControl>
11 changes: 8 additions & 3 deletions src/LiveChartsCore/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using LiveChartsCore.Drawing;
Expand Down Expand Up @@ -388,7 +389,8 @@ NamePadding is not null || SeparatorsPaint is not null || LabelsPaint is not nul

for (var i = start - s; i <= max + s; i += s)
{
var labelContent = i < min || i > max ? string.Empty : labeler(i - 1d + 1d);
var separatorKey = labeler(i - 1d + 1d);
var labelContent = i < min || i > max ? string.Empty : separatorKey;

float x, y;
if (_orientation == AxisOrientation.X)
Expand All @@ -414,14 +416,17 @@ NamePadding is not null || SeparatorsPaint is not null || LabelsPaint is not nul
yc = actualScale.ToPixels(i);
}

if (!separators.TryGetValue(labelContent, out var visualSeparator))
if (_orientation == AxisOrientation.Y) Trace.WriteLine($"@{i:N2}");

if (!separators.TryGetValue(separatorKey, out var visualSeparator))
{
visualSeparator = new AxisVisualSeprator<TDrawingContext>() { Value = i };

if (SeparatorsPaint is not null && ShowSeparatorLines)
{
InitializeSeparator(visualSeparator, cartesianChart);
UpdateSeparator(visualSeparator.Separator!, xc, yc, lxi, lxj, lyi, lyj, UpdateMode.UpdateAndComplete);
if (_orientation == AxisOrientation.Y) Trace.WriteLine($"{i:N2} => {yc:N2}");
}
if (SubseparatorsPaint is not null)
{
Expand All @@ -444,7 +449,7 @@ NamePadding is not null || SeparatorsPaint is not null || LabelsPaint is not nul
UpdateLabel(visualSeparator.Label!, xc, yc, labeler(i - 1d + 1d), hasRotation, r, UpdateMode.UpdateAndComplete);
}

separators.Add(labelContent, visualSeparator);
separators.Add(separatorKey, visualSeparator);
}

if (SeparatorsPaint is not null && ShowSeparatorLines && visualSeparator.Separator is not null)
Expand Down

0 comments on commit 885be37

Please sign in to comment.