File tree 6 files changed +77
-15
lines changed
docs/BlazorApexCharts.Docs/Components 6 files changed +77
-15
lines changed Original file line number Diff line number Diff line change 1
1
<DemoContainer >
2
2
<ApexChart TItem =" Order"
3
- Title =" Order Gross Value" Options =options Debug >
3
+ Title =" Order Gross Value" Options =options >
4
4
5
5
<ApexPointSeries TItem =" Order"
6
6
Items =" Orders"
25
25
return w.config.series[seriesIndex];}"
26
26
};
27
27
28
-
29
28
}
30
- }
29
+ }
Original file line number Diff line number Diff line change 1
1
<DemoContainer >
2
2
<ApexChart TItem =" Order"
3
- Title =" Order Value" >
3
+ Title =" Order Value" OnXAxisLabelClick = XAxisLabelClick >
4
4
5
5
<ApexPointSeries TItem =" Order"
6
6
Items =" orders"
7
7
Name =" Gross Value"
8
8
SeriesType =" SeriesType.Radar"
9
9
XValue =" @(e => e.Country)"
10
10
YAggregate =" @(e => e.Sum(e => e.GrossValue))"
11
- OrderByDescending = " e=>e.Y "
12
- ShowDataLabels />
11
+ ShowDataLabels
12
+ OrderByDescending = " e=>e.Y " />
13
13
14
14
<ApexPointSeries TItem =" Order"
15
15
Items =" orders"
16
16
Name =" Net Value"
17
17
SeriesType =" SeriesType.Radar"
18
18
XValue =" @(e => e.Country)"
19
19
YAggregate =" @(e => e.Sum(e => e.NetValue))"
20
- OrderByDescending =" e=>e.Y"
21
- />
20
+ OrderByDescending =" e=>e.Y" />
22
21
</ApexChart >
23
22
</DemoContainer >
24
23
25
24
@code {
26
25
private List <Order > orders { get ; set ; } = SampleData .GetOrders ();
27
-
28
-
29
-
30
- }
26
+ private void XAxisLabelClick (XAxisLabelClicked < Order > data )
27
+ {
28
+ var gg = data .LabelIndex ;
29
+ }
30
+ }
Original file line number Diff line number Diff line change 12
12
<Basic />
13
13
</Snippet >
14
14
</CodeSnippet >
15
+
16
+ <CodeSnippet Title =" No Axis Chart" ClassName =@typeof(NoAxisChart).ToString() >
17
+ <Snippet >
18
+ <NoAxisChart />
19
+ </Snippet >
20
+ </CodeSnippet >
15
21
</ChildContent >
16
22
17
23
Original file line number Diff line number Diff line change
1
+ <DemoContainer >
2
+ <ApexChart TItem =" Order"
3
+ Title =" Order Gross Value" OnLegendClicked =" LegendClicked" >
4
+
5
+ <ApexPointSeries TItem =" Order"
6
+ Items =" Orders"
7
+ Name =" Gross Value"
8
+ SeriesType =" SeriesType.Pie"
9
+ XValue =" @(e => e.Country)"
10
+ YAggregate =" @(e => e.Sum(e => e.GrossValue))"
11
+ OrderByDescending =" e=>e.Y"
12
+ />
13
+ </ApexChart >
14
+
15
+ @if (currentLegend != null )
16
+ {
17
+ <Alert BackgroundColor =" TablerColor.Primary" >
18
+ <h3 >You clicked @currentLegend.DataPoint.X </h3 >
19
+
20
+ </Alert >
21
+ }
22
+
23
+ </DemoContainer >
24
+
25
+ @code {
26
+ private List <Order > Orders { get ; set ; } = SampleData .GetOrders ();
27
+
28
+
29
+ private LegendClicked <Order > currentLegend = null ;
30
+ protected override void OnInitialized ()
31
+ {
32
+
33
+ }
34
+
35
+ private void LegendClicked (LegendClicked < Order > data )
36
+ {
37
+ currentLegend = data ;
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -146,11 +146,23 @@ public void JSSelected(JSSelection jsSelection)
146
146
[ JSInvokable ]
147
147
public void JSLegendClicked ( JSLegendClicked jsLegendClicked )
148
148
{
149
- var series = ChartReference . Options . Series . ElementAt ( jsLegendClicked . SeriesIndex ) ;
149
+ Series < TItem > series = null ;
150
+ IDataPoint < TItem > point = null ;
151
+ if ( ChartReference . IsNoAxisChart )
152
+ {
153
+ series = ChartReference . Options . Series . First ( ) ;
154
+ point = series . Data . ElementAt ( jsLegendClicked . SeriesIndex ) ;
155
+ }
156
+ else
157
+ {
158
+ series = ChartReference . Options . Series . ElementAt ( jsLegendClicked . SeriesIndex ) ;
159
+ }
160
+
150
161
var legendClicked = new LegendClicked < TItem >
151
162
{
152
163
Series = series ,
153
- Collapsed = jsLegendClicked . Collapsed
164
+ Collapsed = jsLegendClicked . Collapsed ,
165
+ DataPoint = point ,
154
166
} ;
155
167
156
168
//Invert if Toggle series is set to flase (default == true)
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ public class LegendClicked<TItem> where TItem : class
14
14
/// <summary>
15
15
/// Specifies whether the series associated with the legend item is collapsed
16
16
/// </summary>
17
- public bool Collapsed { get ; set ; }
17
+ public bool Collapsed { get ; set ; }
18
+
19
+ /// <summary>
20
+ /// The clicked datapoint, Only valid for no axis charts
21
+ /// </summary>
22
+ public IDataPoint < TItem > DataPoint { get ; set ; }
23
+
18
24
}
19
25
}
You can’t perform that action at this time.
0 commit comments