1+ @page " /animation"
2+
3+ <h3 >Animation</h3 >
4+
5+ <Chart Config =" _config1" @ref =" _chart1" Height =" 400px" ></Chart >
6+
7+ <hr />
8+
9+ <h3 >Code</h3 >
10+
11+ <p >
12+ This is the component to add in your page.
13+ </p >
14+
15+ <CodeSnippet Language =" Language.xml" Style =" Style.VisualStudio" >
16+ <Chart Config="_config1" @ ; ref="_chart1">< ; Chart>
17+ </CodeSnippet >
18+
19+ <p >
20+ Then, in the code section, add the following code:
21+ </p >
22+
23+ <CodeSnippet Language =" Language.csharp" Style =" Style.VisualStudio" LoadMainScript =" false" >
24+ private BarChartConfig? _config1;
25+ private Chart? _chart1;
26+
27+ _config1 = new LineChartConfig()
28+ {
29+ Options = new Options ()
30+ {
31+ Responsive = true ,
32+ MaintainAspectRatio = false ,
33+ Animations = new Animations ()
34+ {
35+ Tension = new Tension ()
36+ {
37+ Duration = 1000 ,
38+ Easing = " linear" ,
39+ From = 1 ,
40+ To = 0 ,
41+ Loop = true
42+ }
43+ },
44+ Scales = new Dictionary & lt ;string , Axis & gt ;()
45+ {
46+ {
47+ Scales .YAxisId , new Axis ()
48+ {
49+ Min = 0 ,
50+ Max = 100
51+ }
52+ }
53+ }
54+ }
55+ } ;
56+
57+ _config1.Data.Labels = LineDataExamples.SimpleLineText;
58+ _config1.Data.Datasets.Add(new LineDataset()
59+ {
60+ Label = " Looping tension" ,
61+ Data = AnimationExamples .SimpleLine .ToList (),
62+ BorderColor = Colors .PaletteBorder1 .FirstOrDefault (),
63+ Fill = false
64+ } );
65+ </CodeSnippet >
66+
67+ @code {
68+ private LineChartConfig ? _config1 ;
69+ private Chart ? _chart1 ;
70+
71+ protected override async Task OnInitializedAsync ()
72+ {
73+ _config1 = new LineChartConfig ()
74+ {
75+ Options = new Options ()
76+ {
77+ Responsive = true ,
78+ MaintainAspectRatio = false ,
79+ Animations = new Animations ()
80+ {
81+ Tension = new Tension ()
82+ {
83+ Duration = 1000 ,
84+ Easing = " linear" ,
85+ From = 1 ,
86+ To = 0 ,
87+ Loop = true
88+ }
89+ },
90+ Scales = new Dictionary <string , Axis >()
91+ {
92+ {
93+ Scales .YAxisId , new Axis ()
94+ {
95+ Min = 0 ,
96+ Max = 100
97+ }
98+ }
99+ }
100+ }
101+ };
102+
103+ _config1 .Data .Labels = LineDataExamples .SimpleLineText ;
104+ _config1 .Data .Datasets .Add (new LineDataset ()
105+ {
106+ Label = " Looping tension" ,
107+ Data = AnimationExamples .SimpleLine .ToList (),
108+ BorderColor = Colors .PaletteBorder1 .FirstOrDefault (),
109+ Fill = false
110+ });
111+ }
112+ }
0 commit comments