0

This question is almost a duplicate of Setting the colour of a LiveCharts Series that has custom labels using XAML Binding

I just want to do the exact thing described there, but on the LiveCharts2 version. The problem I'm facing is that I get

Unable to resolve type LineSeries from namespace using:LiveChartsCore.SkiaSharpView.Avalonia

when i do

xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"

<lvc:CartesianChart>
   <lvc:CartesianChart.Series>
      <lvc:LineSeries Values="{Binding ABValues}" DataLabels="True" FontSize="14" StrokeDashArray="1,1" Fill="{Binding ABColor}" LabelPoint="{Binding ABLabelPoint}"/>      

I tried changing the namespace:

xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:lvc2="using:LiveChartsCore.SkiaSharpView"
xmlns:lvc3="using:LiveChartsCore.Defaults"

and calling LineSeries by using

<lvc2:LineSeries x:TypeArguments="lvc3:ObservableValue" Values="{Binding MyValues}">

beacause the structure of the package seems different. I get

Unable to find suitable setter or adder for property Values of type LiveChartsCore:LiveChartsCore.Series`4 for argument Avalonia.Markup.Xaml:Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindingExtension, available setter parameter lists are:
System.Collections.Generic.IEnumerable`1<LiveChartsCore.Defaults.ObservableValue>
LiveChartsCore.Defaults.ObservableValue

Im sure that im binding to the right type (MyValues is an IEnumerable made from ObservableValues), but i cannot make this work.

How im i supposed to select a color for the plot on the view? now, i do it on the ViewModel, but i cannot apply styles.

1 Answer 1

0

This syntax is not supported in version 2 yet, I am not sure yet if this will be added in this version, to support this syntax we would need to add "framework specific" code for each supported framework, since v2 now supports a lot of frameworks this is much harder to maintain now.

Please just bind the data as the docs in the web site state, here is an example:

https://livecharts.dev/docs/Avalonia/2.0.0-rc2/samples.lines.basic

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.