Pull down to refresh...
Release to refresh...
Refreshing...
-
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
Related Demos:
Your search did not match any results.
Loading...
React Charts - Points Aggregation
This demo illustrates the Chart's data aggregation feature using the line, range area, and bar series. The line series shows temperature changes using average, minimum, or maximum temperature values in the selected time interval. The range area series shows the temperature range for the same time interval and uses a custom aggregate function. The bar series illustrates precipitation and is not aggregated.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
x
import React, { useCallback, useState } from 'react';
import Chart, {
CommonSeriesSettings,
Series,
Aggregation,
Point,
ArgumentAxis,
ValueAxis,
Title,
Font,
Legend,
Label,
Tooltip,
IAggregationProps,
} from 'devextreme-react/chart';
import CheckBox from 'devextreme-react/check-box';
import SelectBox from 'devextreme-react/select-box';
import {
weatherData, aggregationFunctions, aggregationIntervals, functionLabel, intervalLabel,
} from './data.ts';
const customizeTooltip = (pointInfo) => {
const { aggregationInfo } = pointInfo.point;
const start: Date = aggregationInfo && aggregationInfo.intervalStart;
const end: Date = aggregationInfo && aggregationInfo.intervalEnd;
const handlers = {
'Average temperature': (arg: { argument: Date; value: number; }) => ({
text: `${(!aggregationInfo
? `Date: ${arg.argument.toDateString()}`
: `Interval: ${start.toDateString()} - ${end.toDateString()}`)
}<br/>Temperature: ${arg.value.toFixed(2)} °C`,
}),
'Temperature range': (arg: { rangeValue1: number; rangeValue2: number; }) => ({
text: `Interval: ${start.toDateString()
} - ${end.toDateString()
}<br/>Temperature range: ${arg.rangeValue1
} - ${arg.rangeValue2} °C`,
}),
Precipitation: (arg: { argument: Date; valueText: string; }) => ({
text: `Date: ${arg.argument.toDateString()
}<br/>Precipitation: ${arg.valueText} mm`,
}),
};
return handlers[pointInfo.seriesName](pointInfo);
};
function App() {
const [useAggregation, setUseAggregation] = useState(true);
const [currentFunction, setCurrentFunction] = useState(aggregationFunctions[0].func);
const [currentInterval, setCurrentInterval] = useState(aggregationIntervals[0].interval);
const updateAggregationUsage = useCallback(({ value }) => {
setUseAggregation(value);
}, [setUseAggregation]);
const updateInterval = useCallback(({ value }) => {
setCurrentInterval(value);
}, [setCurrentInterval]);
const updateMethod = useCallback(({ value }) => {
setCurrentFunction(value);
}, [setCurrentFunction]);
const calculateRangeArea = useCallback<IAggregationProps['calculate']>((aggregationInfo) => {
if (!aggregationInfo.data.length) {
return null;
}
const temp = aggregationInfo.data.map((item: { temp: number; }) => item.temp);
return {
date: new Date((aggregationInfo.intervalStart.valueOf()
+ aggregationInfo.intervalEnd.valueOf()) / 2),
maxTemp: Math.max.apply(null, temp),
minTemp: Math.min.apply(null, temp),
};
}, []);
return (
<div id="chart-demo">
<Chart
id="chart"
dataSource={weatherData}
>
<CommonSeriesSettings argumentField="date" />
<Series
axis="precipitation"
color="#03a9f4"
type="bar"
valueField="precipitation"
name="Precipitation"
/>
<Series
axis="temperature"
color="#ffc0bb"
type="rangearea"
rangeValue1Field="minTemp"
rangeValue2Field="maxTemp"
name="Temperature range"
>
<Aggregation
enabled={useAggregation}
calculate={calculateRangeArea}
method="custom"
/>
</Series>
<Series
axis="temperature"
color="#e91e63"
valueField="temp"
name="Average temperature"
>
<Point size={7} />
<Aggregation
enabled={useAggregation}
method={currentFunction}
/>
</Series>
<ArgumentAxis
aggregationInterval={currentInterval}
valueMarginsEnabled={false}
argumentType="datetime"
/>
<ValueAxis name="temperature">
<Title text="Temperature, °C">
<Font color="#e91e63" />
</Title>
<Label>
<Font color="#e91e63" />
</Label>
</ValueAxis>
<ValueAxis
name="precipitation"
position="right"
>
<Title text="Precipitation, mm">
<Font color="#03a9f4" />
</Title>
<Label>
<Font color="#03a9f4" />
</Label>
</ValueAxis>
<Legend visible={false} />
<Tooltip
enabled={true}
customizeTooltip={customizeTooltip}
/>
<Title text="Weather in Las Vegas, NV (2017)" />
</Chart>
<div className="options">
<div className="caption">Options</div>
<div className="option">
<CheckBox
value={useAggregation}
onValueChanged={updateAggregationUsage}
text="Aggregation enabled"
/>
</div>
<div className="option">
<span>Interval:</span>
<SelectBox
dataSource={aggregationIntervals}
value={currentInterval}
inputAttr={intervalLabel}
onValueChanged={updateInterval}
displayExpr="displayName"
valueExpr="interval"
/>
</div>
<div className="option">
<span>Method:</span>
<SelectBox
dataSource={aggregationFunctions}
inputAttr={functionLabel}
value={currentFunction}
onValueChanged={updateMethod}
displayExpr="displayName"
valueExpr="func"
/>
</div>
</div>
</div>
);
}
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx