Skip to content

Commit 0c4956c

Browse files
committed
998039: Updated changes.
1 parent 9f0bf65 commit 0c4956c

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed
2.35 KB
Loading

blazor/stock-chart/legend.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,23 @@ To use, add a `LegendItemTemplate` inside any [StockChartSeries](https://help.sy
571571
```
572572
@using Syncfusion.Blazor.Charts
573573
574-
<SfStockChart Title="AAPL vs GOOGL Stock Price" SelectionMode="SelectionMode.Series">
574+
@* Initialize the stock chart component and configure its essential features *@
575+
<SfStockChart Title="AAPL vs GOOGL Stock Price"
576+
SelectionMode="SelectionMode.Series">
577+
578+
@* Display the legend and allow toggling series visibility on interaction *@
575579
<StockChartLegendSettings Visible="true" ToggleVisibility="true" />
580+
576581
<StockChartSeriesCollection>
577-
<StockChartSeries DataSource="@StockDetails" Type="ChartSeriesType.Line" XName="Date" High="High" Low="Low" Open="Open" Close="Close" Name="Apple Stock Price" Fill="red">
582+
583+
@* Define the first series using OHLC fields and render it as a line to show trend *@
584+
<StockChartSeries DataSource="@StockDetails" Type="ChartSeriesType.Line" XName="Date" High="High" Low="Low" Open="Open" Close="Close" Name="Apple Stock Price" Fill="@AppleColor">
585+
@* This legend item contains an emoji indicator, a color swatch, a descriptive label, and a dynamic point count *@
578586
<LegendItemTemplate>
579-
<div style="display:flex; align-items:center; gap:10px; padding:4px 0;">
587+
<div style="display:flex; align-items:center; gap:10px; padding:6px 0;">
580588
<span style="font-size:18px;">🍎</span>
581-
<div style="display:flex; flex-direction:column; line-height:1.15;">
582-
<span style="font-family:'Segoe UI'; font-size:14px; font-weight:700; color:red;">
589+
<div style="display:flex; flex-direction:column; line-height:1.2;">
590+
<span style="font-family:'Segoe UI'; font-size:14px; font-weight:700; color:@AppleColor;">
583591
Apple Stock Price
584592
</span>
585593
<span style="font-size:12px; opacity:0.85;">
@@ -593,12 +601,14 @@ To use, add a `LegendItemTemplate` inside any [StockChartSeries](https://help.sy
593601
</LegendItemTemplate>
594602
</StockChartSeries>
595603
596-
<StockChartSeries DataSource="@StockDetails" Type="ChartSeriesType.Spline" XName="Date" High="High" Low="Low" Open="Open" Close="Close" Name="Google Stock Price" Fill="cornflowerblue">
604+
@* Define the second series using the same OHLC fields and render it as a spline for a smoothed trend *@
605+
<StockChartSeries DataSource="@StockDetails" Type="ChartSeriesType.Spline" XName="Date" High="High" Low="Low" Open="Open" Close="Close" Name="Google Stock Price" Fill="@GoogleColor">
606+
@* This legend item presents an emoji indicator, a color swatch, a descriptive label, and a dynamic point count *@
597607
<LegendItemTemplate>
598-
<div style="display:flex; align-items:center; gap:10px; padding:4px 0;">
608+
<div style="display:flex; align-items:center; gap:10px; padding:6px 0;">
599609
<span style="font-size:18px;">🔍</span>
600-
<div style="display:flex; flex-direction:column; line-height:1.15;">
601-
<span style="font-family:'Segoe UI'; font-size:14px; font-weight:700; color:cornflowerblue;">
610+
<div style="display:flex; flex-direction:column; line-height:1.2;">
611+
<span style="font-family:'Segoe UI'; font-size:14px; font-weight:700; color:@GoogleColor;">
602612
Google Stock Price
603613
</span>
604614
<span style="font-size:12px; opacity:0.85;">
@@ -611,10 +621,14 @@ To use, add a `LegendItemTemplate` inside any [StockChartSeries](https://help.sy
611621
</div>
612622
</LegendItemTemplate>
613623
</StockChartSeries>
624+
614625
</StockChartSeriesCollection>
615626
</SfStockChart>
616627
617628
@code {
629+
private string AppleColor => "#16a34a";
630+
private string GoogleColor => "#2563eb";
631+
618632
public class ChartData
619633
{
620634
public DateTime Date { get; set; }
@@ -628,11 +642,11 @@ To use, add a `LegendItemTemplate` inside any [StockChartSeries](https://help.sy
628642
public List<ChartData> StockDetails = new List<ChartData>
629643
{
630644
new ChartData { Date = new DateTime(2012, 04, 02), Open = 85.9757, High = 90.6657, Low = 85.7685, Close = 90.5257, Volume = 660187068 },
631-
new ChartData { Date = new DateTime(2012, 04, 09), Open = 89.4471, High = 92, Low = 86.2157, Close = 86.4614, Volume = 912634864 },
645+
new ChartData { Date = new DateTime(2012, 04, 09), Open = 89.4471, High = 92, Low = 86.2157, Close = 86.4614, Volume = 912634864 },
632646
new ChartData { Date = new DateTime(2012, 04, 16), Open = 87.1514, High = 88.6071, Low = 81.4885, Close = 81.8543, Volume = 1221746066 },
633647
new ChartData { Date = new DateTime(2012, 04, 23), Open = 81.5157, High = 88.2857, Low = 79.2857, Close = 86.1428, Volume = 965935749 },
634-
new ChartData { Date = new DateTime(2012, 04, 30), Open = 85.4, High = 85.4857, Low = 80.7385, Close = 80.75, Volume = 615249365 }
635-
};
648+
new ChartData { Date = new DateTime(2012, 04, 30), Open = 85.4, High = 85.4857, Low = 80.7385, Close = 80.75, Volume = 615249365 }
649+
};
636650
}
637651
```
638652
![Blazor Stock Chart legend template](images/blazor-stock-chart-legend-template.png)

0 commit comments

Comments
 (0)