-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
- Overview
-
Action Sheet
-
Button
- Floating Action Button
- Drop Down Button
-
Context Menu
-
List
-
Lookup
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
React Charts - SignalR Service
This example demonstrates a real-time data update in a financial candlestick chart bound to a SignalR server. Note that data used in this demo is for demonstration purposes only.
To integrate the Chart with a SignalR server, specify a CustomStore. Use the CustomStore's push(changes) method to insert, update, and remove data objects. This method accepts an array and allows you to update data in batches.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
import React, {
useCallback, useEffect, useRef, useState,
} from 'react';
import Chart, {
ArgumentAxis,
ValueAxis,
Aggregation,
Legend,
Series,
ScrollBar,
ZoomAndPan,
LoadingIndicator,
Pane,
Tooltip,
Crosshair,
Margin,
HorizontalLine,
IAggregationProps,
} from 'devextreme-react/chart';
import { VisualRange } from 'devextreme-react/common/charts';
import CustomStore from 'devextreme/data/custom_store';
import { HubConnectionBuilder, HttpTransportType } from '@aspnet/signalr';
import TooltipTemplate from './TooltipTemplate.tsx';
const minVisualRangeLength = { minutes: 10 };
const defaultVisualRange: VisualRange = { length: 'hour' };
function App() {
const [dataSource, setDataSource] = useState(null);
const chartRef = useRef(null);
const customizePoint = useCallback((arg) => {
if (arg.seriesName === 'Volume') {
const point = chartRef.current.instance().getAllSeries()[0]
.getPointsByArg(arg.argument)[0].data;
if (point && point.close >= point.open) {
return { color: '#1db2f5' };
}
}
return null;
}, []);
const calculateCandle = useCallback<IAggregationProps['calculate']>((e) => {
const prices = e.data.map((d) => d.price);
if (prices.length) {
return {
date: new Date((e.intervalStart.valueOf() + e.intervalEnd.valueOf()) / 2),
open: prices[0],
high: Math.max.apply(null, prices),
low: Math.min.apply(null, prices),
close: prices[prices.length - 1],
};
}
return null;
}, []);
useEffect(() => {
const hubConnection = new HubConnectionBuilder()
.withUrl('https://js.devexpress.com/Demos/NetCore/stockTickDataHub', {
skipNegotiation: true,
transport: HttpTransportType.WebSockets,
})
.build();
const store = new CustomStore({
load: () => hubConnection.invoke('getAllData'),
key: 'date',
});
hubConnection
.start()
.then(() => {
hubConnection.on('updateStockPrice', (data) => {
store.push([{ type: 'insert', key: data.date, data }]);
});
setDataSource(store);
});
}, []);
return (
<div>
<Chart
id="chart"
ref={chartRef}
dataSource={dataSource}
title="Stock Price"
customizePoint={customizePoint}>
<Margin right={30} />
<Series
pane="Price"
argumentField="date"
type="candlestick">
<Aggregation
enabled={true}
method="custom"
calculate={calculateCandle} />
</Series>
<Series
pane="Volume"
name="Volume"
argumentField="date"
valueField="volume"
color="red"
type="bar">
<Aggregation
enabled={true}
method="sum" />
</Series>
<Pane name="Price"></Pane>
<Pane name="Volume" height={80}></Pane>
<Legend visible={false} />
<ArgumentAxis
argumentType="datetime"
minVisualRangeLength={minVisualRangeLength}
defaultVisualRange={defaultVisualRange} />
<ValueAxis placeholderSize={50} />
<ZoomAndPan argumentAxis="both" />
<ScrollBar visible={true} />
<LoadingIndicator enabled={true} />
<Tooltip
enabled={true}
shared={true}
argumentFormat="shortDateShortTime"
contentRender={TooltipTemplate}
/>
<Crosshair
enabled={true}>
<HorizontalLine visible={false} />
</Crosshair>
</Chart>
</div>
);
}
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
To display updated data in real time, use the aggregation configuration object. In this object, set the enabled property to true, the method property to custom
, and then implement the calculate function to process the incoming data. In this demo, the calculate function aggregates data into a one point for each interval.
You can also use the contentTemplate function to update the tooltip content with incoming data.