示例#1
0
        /// <summary>
        /// Adds the new data point(s) to the specified dataset.
        /// </summary>
        /// <param name="dataSetIndex">Dataset index to which we add the data point(s).</param>
        /// <param name="data">Data point(s) to add.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public async Task AddData(int dataSetIndex, params TItem[] data)
        {
            dirty = true;

            Datasets[dataSetIndex].Data.AddRange(data);

            if (initialized)
            {
                await JSModule.AddData(ElementId, dataSetIndex, data);
            }
        }
        public async Task Refresh()
        {
            if (!Rendered)
            {
                return;
            }

            foreach (var dataset in ParentChart?.Data?.Datasets ?? Enumerable.Empty <ChartDataset <TItem> >())
            {
                var datasetIndex = ParentChart.Data.Datasets.IndexOf(dataset);

                var newData = new ChartStreamingData <TItem>(dataset.Label, datasetIndex);

                await Refreshed.InvokeAsync(newData);

                await JSModule.AddData(ParentChart.ElementId, newData.DatasetIndex, newData.Value);
            }
        }