I am trying to create a Bar Plot in WPF xaml, I want bars in differenct categories, like it’s documented here: ScottPlot Cookbook
I also used this for knowing how it works with WPF: ScottPlot WPF Quickstart
I got this code now:
public Statistieken()
{
InitializeComponent();
Loaded += (s, e) =>
{
double[] xs1 = { 1, 2, 3, 4 };
double[] ys1 = { 5, 10, 7, 13 };
BarPlot bars1 = WpfPlot.Plot.AddBar(ys1, xs1);
bars1.Label = "Alpha";
double[] xs2 = { 6, 7, 8, 9 };
double[] ys2 = { 7, 12, 9, 15 };
BarPlot bars2 = WpfPlot.Plot.AddBar(ys2, xs2);
bars2.Label = "Beta";
WpfPlot.Plot.Legend(location: Alignment.UpperLeft);
WpfPlot.Refresh();
};
}
I just cannot get it to work, this line always gives an error: BarPlot bars1 = WpfPlot.Plot.AddBar(ys1, xs1);
I tried lots of things using ChatGPT too, also exactly what is documented in the Documentation, I can create it all in the xaml.cs, but then adding it to the xaml is the problem.