# Blazor Gauges and Stock Chart

URL: https://flexcoreui.com/demo/gauges  
Section: Charts  
Controls: ArcGaugeControl, CircularGaugeControl, RadialGaugeControl, LinearGaugeControl, StockChartControl  
Keywords: gauge, circular gauge, linear gauge, radial gauge, stock chart, candlestick

Show one value at a glance: arc, circular, radial and linear Blazor gauges sharing one set of parameters, plus a candlestick stock chart.

## Documentation

### Gauge

| Name | Type | Default | Description |
|---|---|---|---|
| Value | double | 0 | The reading. Drawn and announced clamped into Min to Max. |
| Min | double | 0 | Start of the scale. |
| Max | double | 100 | End of the scale; must be above Min. |
| Ranges | IReadOnlyList<GaugeRange> | Array.Empty<GaugeRange>() | Colored bands along the scale, each with a label for its tooltip. |
| Pointers | IReadOnlyList<GaugePointer> | Array.Empty<GaugePointer>() | Extra markers: needles on the round gauges, vertical marks on the linear one, each with a color and a label. |
| Color | string | "#2563eb" | Color of the value arc or bar and of the radial gauge's needle. |
| TickCount | int | 5 | Number of intervals on the scale, 1 to 100; one label per interval boundary. |
| LabelFormat | string | "0" | Numeric format of the tick labels. |
| ValueFormat | string | "0.##" | Numeric format of the printed value. |
| Height | string | "260px" | Height of the drawing; the width follows the container. |
| AriaLabel | string | "Gauge" | Accessible name of the meter. |
| ValueTemplate | RenderFragment<GaugeValueContext>? | null | Replaces the printed value with your own content, centered over the gauge; receives value, min and max. |

### Stock

| Name | Type | Default | Description |
|---|---|---|---|
| DataSource | IEnumerable<ChartDataPoint> | Array.Empty<ChartDataPoint>() | The financial points; each needs DateValue. Sorted by date on arrival. |
| Type | ChartType | ChartType.Candlestick | Candlestick, Ohlc or HighLow; anything else throws. |
| Start | DateTime? | null | First visible date. Null means the first point; re-applied when the value changes, clamped to the data. |
| End | DateTime? | null | Last visible date. Null means the last point; re-applied when the value changes, clamped to the data. |
| Height | string | "340px" | Height of the main chart; the navigator adds 90 px. |
| ValueFormat | string | "N2" | Numeric format of the price axis and values. |
| ShowNavigator | bool | true | Shows the strip of closing prices with the start and end sliders. |
| ColorPalette | string[]? | null | Handed to both inner charts: the high-low line and the navigator's closing-price line take entry 0. |
| UpColor | string? | null | Handed to the price chart: rising candles and OHLC bars. Unset, the built-in green. |
| DownColor | string? | null | Handed to the price chart: falling candles and OHLC bars. Unset, the built-in red. |

### Stock events

| Name | Type | Description |
|---|---|---|
| RangeChanged | StockChartRange | After every change of the visible range: pickers, buttons, sliders or the methods. |

### Stock methods

| Name | Type | Description |
|---|---|---|
| SetRangeAsync(DateTime? start, DateTime? end) | Task | Sets the visible range from code; null falls back to the first or last point, dates outside the data are clamped, and start after end throws. Raises RangeChanged. |
| ZoomAsync(double factor) | Task | Multiplies the visible span by the factor around its center, never below one day; the toolbar uses 0.5 and 2. |
| PanAsync(int direction) | Task | Slides the range by half its span, earlier for a negative direction and later for a positive one, clamped to the data. |

### Css

| Name | Description |
|---|---|
| fx-gauge | A gauge's root element; fx-gauge-value-template is the centered template. |
| fx-stock-chart | The stock chart's root; fx-stock-navigator is the strip with the sliders. |

## Examples

### Gauges

```razor
@using Fx.ControlKit
@using Fx.ControlKit.Charts

<ButtonControl CssClass="btn-sm" OnClick="() => _value = Math.Max(0, _value - 10)" Disabled="@(_value <= 0)">−10</ButtonControl>
<ButtonControl CssClass="btn-sm" OnClick="() => _value = Math.Min(100, _value + 10)" Disabled="@(_value >= 100)">+10</ButtonControl>

<div class="four">
    <div><p class="pane-title">Arc</p><ArcGaugeControl Value="@_value" Ranges="@_ranges" Color="@ChartPalette.Blue" AriaLabel="Utilization" Height="300px" /></div>
    <div>
        <p class="pane-title">Circular</p>
        <CircularGaugeControl Value="@_value" TickCount="10" Color="@ChartPalette.Green" AriaLabel="Progress" Height="300px">
            <ValueTemplate Context="g"><strong class="ring-value">@g.Value of @g.Max</strong></ValueTemplate>
        </CircularGaugeControl>
    </div>
    <div><p class="pane-title">Radial</p><RadialGaugeControl Value="@_value" Pointers="@_target" Color="@ChartPalette.Indigo" AriaLabel="Throughput" Height="300px" /></div>
    <div><p class="pane-title">Linear</p><LinearGaugeControl Value="@_value" Ranges="@_ranges" Pointers="@_target" Color="@ChartPalette.Blue" LabelFormat="0'%'" ValueFormat="0'%'" AriaLabel="Capacity" Height="150px" /></div>
</div>
```

### Stock

```razor
@using Fx.ControlKit
@using Fx.ControlKit.Charts

<ButtonControl CssClass="btn-sm" OnClick="() => _stock!.SetRangeAsync(_prices[^5].DateValue, null)">Last 5 trading days</ButtonControl>
<ButtonControl CssClass="btn-sm" OnClick="() => _stock!.SetRangeAsync(_firstShown, null)">Last 14 trading days</ButtonControl>
<ButtonControl CssClass="btn-sm" OnClick="() => _type = _type == ChartType.Candlestick ? ChartType.Ohlc : ChartType.Candlestick">Show as @(_type == ChartType.Candlestick ? "OHLC" : "candlesticks")</ButtonControl>

<StockChartControl @ref="_stock" DataSource="@_prices" Type="@_type" UpColor="@ChartPalette.Green" DownColor="@ChartPalette.Rose" Start="@_firstShown" Height="400px" ShowNavigator="false" RangeChanged="r => _range = Describe(r.Start, r.End)" />
<p class="result">Range: @_range</p>
```

