|
1 | | -using Microsoft.AspNetCore.Components; |
2 | | -using System; |
3 | | -using System.Collections.Generic; |
4 | | - |
5 | | -namespace ApexCharts |
6 | | -{ |
| 1 | +using Microsoft.AspNetCore.Components; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Threading.Tasks; |
| 5 | + |
| 6 | +namespace ApexCharts |
| 7 | +{ |
7 | 8 | /// <summary> |
8 | 9 | /// Component to create a single-value <see cref="SeriesType.RadialBar"/> chart in Blazor |
9 | | - /// </summary> |
10 | | - public partial class ApexGauge : IDisposable |
11 | | - { |
12 | | - /// <inheritdoc cref="Title.Text"/> |
13 | | - [Parameter] public string Title { get; set; } |
14 | | - |
15 | | - /// <inheritdoc cref="GaugeValue.Percentage"/> |
16 | | - [Parameter] public decimal Percentage { get; set; } |
17 | | - |
18 | | - /// <inheritdoc cref="GaugeValue.Label"/> |
19 | | - [Parameter] public string Label { get; set; } |
20 | | - |
| 10 | + /// </summary> |
| 11 | + public partial class ApexGauge : IDisposable |
| 12 | + { |
| 13 | + /// <inheritdoc cref="Title.Text"/> |
| 14 | + [Parameter] public string Title { get; set; } |
| 15 | + |
| 16 | + /// <inheritdoc cref="GaugeValue.Percentage"/> |
| 17 | + [Parameter] public decimal Percentage { get; set; } |
| 18 | + |
| 19 | + /// <inheritdoc cref="GaugeValue.Label"/> |
| 20 | + [Parameter] public string Label { get; set; } |
| 21 | + |
21 | 22 | /// <summary> |
22 | 23 | /// The options to customize the radial bar chart with |
23 | | - /// </summary> |
24 | | - [Parameter] public ApexChartOptions<GaugeValue> Options { get; set; } = new ApexChartOptions<GaugeValue>(); |
25 | | - |
| 24 | + /// </summary> |
| 25 | + [Parameter] public ApexChartOptions<GaugeValue> Options { get; set; } = new ApexChartOptions<GaugeValue>(); |
| 26 | + |
26 | 27 | private ApexChartOptions<GaugeValue> options; |
27 | 28 |
|
28 | | - /// <inheritdoc/> |
29 | | - protected override void OnInitialized() |
30 | | - { |
31 | | - options = Options; |
32 | | - } |
33 | | - |
34 | | - private List<GaugeValue> GetItems() |
35 | | - { |
36 | | - return new List<GaugeValue> { new GaugeValue { Label = Label, Percentage = Percentage } }; |
37 | | - } |
38 | | - |
39 | | - /// <inheritdoc/> |
40 | | - public void Dispose() |
41 | | - { |
42 | | - GC.SuppressFinalize(this); |
43 | | - } |
44 | | - } |
45 | | -} |
| 29 | + ApexChart<GaugeValue> GaugeReference; |
| 30 | + |
| 31 | + /// <inheritdoc/> |
| 32 | + protected override void OnInitialized() |
| 33 | + { |
| 34 | + options = Options; |
| 35 | + } |
| 36 | + |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Allows you to update the series array overriding the existing one. If you want to append series to existing series, use the appendSeries() method |
| 40 | + /// </summary> |
| 41 | + /// <param name="animate">Should the chart animate on re-rendering</param> |
| 42 | + /// <remarks> |
| 43 | + /// Links: |
| 44 | + /// |
| 45 | + /// <see href="https://apexcharts.github.io/Blazor-ApexCharts/methods/update-series">Blazor Example</see>, |
| 46 | + /// <see href="https://apexcharts.com/docs/methods/#updateSeries">JavaScript Documentation</see> |
| 47 | + /// </remarks> |
| 48 | + public Task UpdateValueAsync(bool animate = true) => |
| 49 | + GaugeReference?.UpdateSeriesAsync(animate); |
| 50 | + |
| 51 | + private List<GaugeValue> GetItems() |
| 52 | + { |
| 53 | + return new List<GaugeValue> { new GaugeValue { Label = Label, Percentage = Percentage } }; |
| 54 | + } |
| 55 | + |
| 56 | + /// <inheritdoc/> |
| 57 | + public void Dispose() |
| 58 | + { |
| 59 | + GC.SuppressFinalize(this); |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments