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

[Feature Request] Subplot for Shared X Axis and Seperated Y Axes #1747

Closed
c0nstexpr opened this issue Dec 28, 2024 · 1 comment
Closed

[Feature Request] Subplot for Shared X Axis and Seperated Y Axes #1747

c0nstexpr opened this issue Dec 28, 2024 · 1 comment

Comments

@c0nstexpr
Copy link

c0nstexpr commented Dec 28, 2024

Currently library already provide multi-axes support, but they're plot together in one area.
I want them to be in seperated regions, but keep using the same X axis.
I use shared axes features to achieve a close result, but have a hard time eliminating the gaps between charts on X axes.

Exactly, I want such plot:
image

@c0nstexpr c0nstexpr changed the title [Feature Request] Subplot for shared X Axis and Seperated Y Axis [Feature Request] Subplot for Shared X Axis and Seperated Y Axis Dec 28, 2024
@c0nstexpr c0nstexpr changed the title [Feature Request] Subplot for Shared X Axis and Seperated Y Axis [Feature Request] Subplot for Shared X Axis and Seperated Y Axes Dec 28, 2024
@beto-rodriguez
Copy link
Owner

Hello

I think this is supported already, i was able to build it using the DrawMargin property, this way you can remove that gap you require.

<Grid RowDefinitions="*,*,*">
    <lvc:CartesianChart
      Grid.Row="0"
      Series="{Binding Series0}"
      XAxes="{Binding X0}"
      YAxes="{Binding Y0}"
      DrawMargin="{Binding M0}"/>
    <lvc:CartesianChart
      Grid.Row="1"
      Series="{Binding Series1}"
      XAxes="{Binding X1}"
      YAxes="{Binding Y1}"
      DrawMargin="{Binding M1}"/>
    <lvc:CartesianChart
      Grid.Row="2"
      Series="{Binding Series2}"
      XAxes="{Binding X2}"
      YAxes="{Binding Y2}"
      DrawMargin="{Binding M2}"/>
</Grid>
public class ViewModel
{
    public ISeries[] Series0 { get; set; } =
        [new LineSeries<double>([14, 13, 14, 15, 17])];

    public ISeries[] Series1 { get; set; } =
        [new LineSeries<double>([14, 13, 14, 15, 17])];

    public ISeries[] Series2 { get; set; } =
        [new LineSeries<double>([14, 13, 14, 15, 17])];

    public ICartesianAxis[] Y0 { get; set; } =
        [new Axis { InLineNamePlacement = true }];

    public ICartesianAxis[] Y1 { get; set; } =
        [new Axis { }];

    public ICartesianAxis[] Y2 { get; set; } =
        [new Axis { }];

    public ICartesianAxis[] X0 { get; set; } =
        [new Axis { IsVisible = false }];

    public ICartesianAxis[] X1 { get; set; } =
        [new Axis { IsVisible = false }];

    public ICartesianAxis[] X2 { get; set; } =
        [new Axis { }];

    public LiveChartsCore.Measure.Margin M0 { get; set; } =
        new(50, 15, 0, 15);

    public LiveChartsCore.Measure.Margin M1 { get; set; } =
        new(50, 15, 0, 15);

    public LiveChartsCore.Measure.Margin M2 { get; set; } =
        new(50, 15, 0, LiveChartsCore.Measure.Margin.Auto);

image

I will close this for now, but feel free to reply if you require further assitance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants