Loading...
Loading...
Implement Syncfusion Blazor Stock Chart (SfStockChart) for financial data visualization. Use this when working with stock charts, candlestick displays, OHLC data, or technical indicators like SMA, EMA, MACD, and Bollinger Bands. This skill covers period selectors, range navigation, and financial time-series data visualization in Blazor applications.
npx skill4agent add syncfusion/blazor-ui-components-skills syncfusion-blazor-stock-chartsSfStockChartStockChartEventsOnLoadedOnPointClickAxisLabelRenderingPeriodChangedRangeChangeOnZoomingTooltipRenderingSharedTooltipRenderingExportingExportCompletedOnPrintComplete@page "/stock-chart"
@using Syncfusion.Blazor.Charts
<SfStockChart Title="AAPL Stock Price" Height="450px">
<StockChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime">
</StockChartPrimaryXAxis>
<StockChartSeriesCollection>
<StockChartSeries DataSource="@StockData" Type="ChartSeriesType.Candle"
XName="Date" High="High" Low="Low" Open="Open" Close="Close">
</StockChartSeries>
</StockChartSeriesCollection>
<StockChartPeriods>
<StockChartPeriod Text="1M" Interval="1" IntervalType="RangeIntervalType.Months"></StockChartPeriod>
<StockChartPeriod Text="3M" Interval="3" IntervalType="RangeIntervalType.Months"></StockChartPeriod>
<StockChartPeriod Text="6M" Interval="6" IntervalType="RangeIntervalType.Months"></StockChartPeriod>
<StockChartPeriod Text="1Y" Interval="1" IntervalType="RangeIntervalType.Years"></StockChartPeriod>
<StockChartPeriod Text="All"></StockChartPeriod>
</StockChartPeriods>
</SfStockChart>
@code {
public class StockInfo
{
public DateTime Date { get; set; }
public double Open { get; set; }
public double High { get; set; }
public double Low { get; set; }
public double Close { get; set; }
public double Volume { get; set; }
}
public List<StockInfo> StockData = new List<StockInfo>
{
new StockInfo { Date = new DateTime(2024, 01, 01), Open = 175.5, High = 180.2, Low = 174.8, Close = 179.5, Volume = 12000000 },
new StockInfo { Date = new DateTime(2024, 02, 01), Open = 179.5, High = 185.3, Low = 178.1, Close = 183.7, Volume = 15000000 },
new StockInfo { Date = new DateTime(2024, 03, 01), Open = 183.7, High = 190.5, Low = 182.5, Close = 188.2, Volume = 18000000 },
// Add more data points...
};
}<SfStockChart Title="Stock Analysis with SMA and RSI">
<StockChartSeriesCollection>
<StockChartSeries DataSource="@StockData" Type="ChartSeriesType.Candle"
XName="Date" High="High" Low="Low" Open="Open" Close="Close">
</StockChartSeries>
</StockChartSeriesCollection>
<StockChartIndicators>
<StockChartIndicator Type="TechnicalIndicators.Sma" Period="14" Field="FinancialDataFields.Close">
</StockChartIndicator>
<StockChartIndicator Type="TechnicalIndicators.Rsi" Period="14" ShowZones="true">
</StockChartIndicator>
</StockChartIndicators>
</SfStockChart><SfStockChart Title="Tech Stocks Comparison">
<StockChartSeriesCollection>
<StockChartSeries DataSource="@AppleData" Type="ChartSeriesType.Line" Name="AAPL"
XName="Date" YName="Close">
</StockChartSeries>
<StockChartSeries DataSource="@MicrosoftData" Type="ChartSeriesType.Line" Name="MSFT"
XName="Date" YName="Close">
</StockChartSeries>
<StockChartSeries DataSource="@GoogleData" Type="ChartSeriesType.Line" Name="GOOGL"
XName="Date" YName="Close">
</StockChartSeries>
</StockChartSeriesCollection>
</SfStockChart><SfStockChart Title="AAPL with Corporate Events">
<StockChartSeriesCollection>
<StockChartSeries DataSource="@StockData" Type="ChartSeriesType.Candle"
XName="Date" High="High" Low="Low" Open="Open" Close="Close">
</StockChartSeries>
</StockChartSeriesCollection>
<StockChartEvents>
<StockChartEvent Date="new DateTime(2024, 02, 01)" Text="Q1 Earnings" Type="@SplineType.Circle">
</StockChartEvent>
<StockChartEvent Date="new DateTime(2024, 03, 15)" Text="Dividend $0.24" Type="@SplineType.Square">
</StockChartEvent>
</StockChartEvents>
</SfStockChart><SfStockChart Title="Bitcoin Price and Volume">
<StockChartRows>
<StockChartRow Height="70%"></StockChartRow>
<StockChartRow Height="30%"></StockChartRow>
</StockChartRows>
<StockChartAxes>
<StockChartAxis Name="VolumeAxis" OpposedPosition="true" RowIndex="1">
</StockChartAxis>
</StockChartAxes>
<StockChartSeriesCollection>
<StockChartSeries DataSource="@BitcoinData" Type="ChartSeriesType.Candle"
XName="Date" High="High" Low="Low" Open="Open" Close="Close">
</StockChartSeries>
<StockChartSeries DataSource="@BitcoinData" Type="ChartSeriesType.Column" Name="Volume"
XName="Date" YName="Volume" YAxisName="VolumeAxis">
</StockChartSeries>
</StockChartSeriesCollection>
</SfStockChart>@using Syncfusion.Blazor.Charts
<button class="btn btn-primary" @onclick="ExportChart">Export to PDF</button>
<SfStockChart @ref="StockChartRef" Title="Annual Stock Performance">
<StockChartSeriesCollection>
<StockChartSeries DataSource="@StockData" Type="ChartSeriesType.Candle"
XName="Date" High="High" Low="Low" Open="Open" Close="Close">
</StockChartSeries>
</StockChartSeriesCollection>
</SfStockChart>
@code {
SfStockChart StockChartRef;
private async Task ExportChart()
{
await StockChartRef.ExportAsync(ExportType.PDF, "StockReport");
}
}| Property | Type | Purpose |
|---|---|---|
| string | Main chart title |
| string | Chart dimensions (e.g., "450px", "100%") |
| Theme | Visual theme (Material, Bootstrap, Fluent, etc.) |
| bool | Show/hide period selector (default: true) |
| bool | Show/hide range selector (default: true) |
| bool | Allow custom date range input |
SfStockChartBackgroundDataSourceSeriesTypeIndicatorTypeTrendlineTypeThemeTitleHeightWidthExportAsync()PrintAsync()Refresh()UpdateStockChart()StockChartSeriesCollectionStockChartIndicatorsStockChartTrendlinesStockChartPeriodsStockChartEventsStockChartAxes| Property | Type | Purpose |
|---|---|---|
| ChartSeriesType | Series type (Candle, Line, Hilo, etc.) |
| object | Data collection |
| string | Property name for X-axis (Date) |
| string | OHLC property names |
| string | Property for Line/Spline series |
| string | Series color |
| Property | Type | Purpose |
|---|---|---|
| string | Button label (e.g., "1M", "6M", "1Y") |
| int | Number of intervals |
| RangeIntervalType | Days, Months, Years |
| bool | Default selected period |