Skip to content

How do I pass an ObservableCollection<KeyValuePair<double,string>> to a PieChart? #437

Discussion options

You must be logged in to vote

If you haven't solved your issue, here is an example how to populate PieChart using Linq:

      IEnumerable<ISeries> result = this.DataRecords
            .Where(w => w.TimeNow.Date == this.SelectedDate.Date)
            .GroupBy(g => g.Running)
            .Select(item => new PieSeries<double>
            {
              Values = new List<double> { item.Sum(x => x.SecondsElapsed) },
              Name = item.Key ? "On" : "Off",
              AnimationsSpeed = new TimeSpan(0, 0, 0),
            });

      this.ChartSeries = new ObservableCollection<ISeries>(result);

and

    private IEnumerable<ISeries> chartSeries;
    public IEnumerable<ISeries> ChartSeries
    {
      get => this.chart…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dennis-Scheurer-zz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants