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

How to add custom axis #39

Open
fizzikzz opened this issue Nov 10, 2021 · 1 comment
Open

How to add custom axis #39

fizzikzz opened this issue Nov 10, 2021 · 1 comment

Comments

@fizzikzz
Copy link

If I make a custom axis using an OxyPlot.LinearAxis as the base class like:

public class CustomLinearAxis : LinearAxis
{
}

The background on my usercontrol hosting the PlotView that uses the custom axis turns black. It seems like it doesn't style properly.

Is there a way to add custom axes in OxyPlot-Avalonia properly?

@VisualMelon
Copy link
Contributor

I can't reproduce a black screen using an empty override like you describe, though OxyPlot.LinearAxis doesn't exist; you need either OxyPlot.Axes.LinearAxis or OxyPlot.Avalonia.LinearAxis: the former is the normal linear-axis model, the latter you can use in XAML bindings and all that.

For example, here you could add an instance of CustomLinearAxis to PlotModel.Axes, or include a CustomAxis in Plot.Axes (e.g. in XAML):

public class CustomAxis : OxyPlot.Avalonia.LinearAxis
{
    public CustomAxis()
    {
        InternalAxis = new CustomLinearAxis();
    }
}

public class CustomLinearAxis : LinearAxis
{
    public override void GetTickValues(out IList<double> majorLabelValues, out IList<double> majorTickValues, out IList<double> minorTickValues)
    {
        base.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues);
        minorTickValues.Clear();
    }
}

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