Code Monkey home page Code Monkey logo

Comments (12)

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

You don't need to raise property changed event, Live charts should detect automatically the changes, there is actually one exmaple included in test project, you can clone the repo to see it, or watch it here:

XAML

https://github.com/beto-rodriguez/Live-Charts/blob/master/ChartsTest/Pie%20Examples/MvvmPie.xaml

Code Behind

https://github.com/beto-rodriguez/Live-Charts/blob/master/ChartsTest/Pie%20Examples/MvvmPie.xaml.cs

Hope it helps, if this does not solves your issue please let me know.

from live-charts.

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

Forgot to mention that VM.Obj.Prop should be an observable collection, otherwise it wont update automatically, try instead

public ObservableCollection Prop {get;set;}

from live-charts.

gregsdennis avatar gregsdennis commented on May 18, 2024

If you are editing the existing collection, you don't need to raise PropertyChanged. If you are reassigning the property, you do, and the control needs to respond to it to redraw.

Probably just needs a handler in the dependency property.

from live-charts.

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

it already has a handler in the dependency property.

from live-charts.

ruzovvo avatar ruzovvo commented on May 18, 2024

Hi again. I tried what you've suggested with ObservableCollection. Now it works almost fine. Thank you for it.
But there are still 2 problems I'd like to avoid:

  1. each redraw is being processed from initial state but not from the previous state of collection
  2. look at pic attached. After redraw I have artifact numbers left from previous collection state. Sometimes these artifacts are being collected during several redraws so my numbers look like mess. I marked it with arrows
    piechart

from live-charts.

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

I will try to force this bug, can you please show me some parts of your code, So it can be easier for me?

from live-charts.

ruzovvo avatar ruzovvo commented on May 18, 2024

public ObservableCollection Spectrum
{
get { return _spectrum; }
set
{
_spectrum = value;
RaisePropertyChanged(() => Spectrum);
}
}

Modification happens 1 time per second:

Spectrum.Clear();
Spectrum.Add(val1);
Spectrum.Add(val2);
Spectrum.Add(val3);
Spectrum.Add(val3);

from live-charts.

ruzovvo avatar ruzovvo commented on May 18, 2024

Can you say smth about my 1st question regarding redrawing from initial state?

from live-charts.

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

the easiest solution, since you are updating the chart each second should be to disable animations, Set the DisableAnimation Property to ttue in your Pie Chart, right now pie chart only support full redraw animation, to support animation that starts from current state it is necesary to do an important improvements to PieSerie class, I will open a new issue to add this in a future, by now disable animations please.

from live-charts.

ruzovvo avatar ruzovvo commented on May 18, 2024

Beto, I've found 1 more problem.
this approach does not work:

<liveCharts:PieChart Name="Spectrum" Grid.Row="0" Grid.Column="0" DisableAnimation="True">
    <liveCharts:PieChart.Series>
        <liveCharts:PieSeries Title="Maria" PrimaryValues="{Binding Obj.Prop}"
                 Labels="{Binding Obj.PropDesc}" />
    </liveCharts:PieChart.Series>
</liveCharts:PieChart>

updates don't come. but if I bind like this:

<liveCharts:PieChart Name="Spectrum" Grid.Row="0" Grid.Column="0" DisableAnimation="True" Series="{Binding PropSeries}"/>

and manually do in viewmodel:

PropSeries.Add(new PieSeries() { PrimaryValues = Obj.Prop });

where PropSeries is and ObservableCollection then piechart will be updating on collection Obj.Prop changes. Please take a look

from live-charts.

beto-rodriguez avatar beto-rodriguez commented on May 18, 2024

@ruzovvo I will take a look, it seems that the handler is not beeing attached if you initialize it with XAML, I will take a look and let you know as soon as possible, Thanks for reporting

from live-charts.

ZaJra avatar ZaJra commented on May 18, 2024

ruzovvo do you still have the code for realtime pi chart?

from live-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.