public async Task RefreshChartData() { IEnumerable <DashboardChartData> newDatas = await GenerateChartDatas.Invoke(); await Chart.Clear(); await Chart.AddLabels(newDatas.Select(x => x.Label).ToArray()); List <string> colors = new List <string>(); for (int i = 0; i < newDatas.Count(); i++) { string lineColor = PointColorGenerator?.Invoke(i); if (!string.IsNullOrWhiteSpace(lineColor)) { colors.Add(lineColor); } else { colors.Add(DEFAULT_POINT_COLOR); } } LineChartDataset <DashboardChartDatasetYValue> newChartDataset = new LineChartDataset <DashboardChartDatasetYValue>() { Data = newDatas.Select(x => new DashboardChartDatasetYValue() { Y = x.Value, DataId = x.DataId }).ToList(), Fill = true, BackgroundColor = DEFAULT_FILL_COLOR, PointBackgroundColor = colors, PointBorderColor = colors, PointRadius = 3.5f }; CurrentDataset = newChartDataset; await Chart.AddDataSet(newChartDataset); await Chart.Update(); }