How can I help you?
Gradient in React Chart control
13 Mar 202624 minutes to read
Gradients add depth and modern styling to charts by smoothly blending multiple colors. The Charts component supports two gradient types:
- Linear gradient
- Radial gradient
Gradients can be applied to:
- Series
- Trendlines
- Technical Indicators
Linear gradient
A linear gradient blends color along side a straight path from a defined start point to an end point. Configure it by adding linearGradient inside the target element (Series, Trendlines or Indicators) and define one or more color stops that control how colors transition across the gradient. Set the start and end positions of the gradient using x1, y1, x2 and y2 properties. The gradient color stop values such as offset, color, opacity, lighten and brighten are set using the gradientColorStop property.
In the linearGradient:
-
x1- Sets the horizontal start position of the gradient (0 to 1). -
y1- Sets the vertical start position of the gradient (0 to 1). -
x2- Sets the horizontal end position of the gradient (0 to 1). -
y2- Sets the vertical end position of the gradient (0 to 1).
In the gradientColorStop:
-
offset- Specifies the position of the color stop along the gradient (0 to 100). -
color- Sets the color at the stop. -
opacity- Defines the transparency of the stop (0 to 1). -
lighten- Adjusts lightness at the stop. Positive values lighten the color. Range: 0 to 1. -
brighten- Adjusts brightness at the stop. Positive values increase brightness; negative values decrease it. Ranges: -1 to 1.
Series
Apply a linear gradient to a series by adding linearGradient inside the target Series. The same gradient is applied to the series markers, legend symbol and tooltip marker for visual consistency.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Tooltip, Legend, Category, DataLabel } from '@syncfusion/ej2-react-charts';
import { SalesData } from './datasource';
function App() {
const primaryXAxis = { valueType: 'Category' };
const primaryYAxis = { labelFormat: '${value}k' };
const linearGradient = { x1: 0, y1: 0, x2: 0, y2: 1,
gradientColorStop: [
{ color: '#4F46E5', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#22D3EE', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
const marker = { visible: true, isFilled: true, dataLabel: { visible: true } };
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis}
title="Monthly Sales Performance" tooltip={{ enable: true }} legendSettings={{ visible: true }}>
<Inject services={[ColumnSeries, Tooltip, Legend, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={SalesData} xName="Month" yName="Amount" name="Sales" type="Column" linearGradient={linearGradient} marker={marker}/>
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Tooltip,
Legend, Category, DataLabel
} from '@syncfusion/ej2-react-charts';
import { SalesData } from './datasource';
function App() {
const primaryXAxis: AxisModel = { valueType: 'Category' };
const primaryYAxis: AxisModel = { labelFormat: '${value}k' };
const linearGradient = {
x1: 0, y1: 0,
x2: 0, y2: 1,
gradientColorStop: [
{ color: '#4F46E5', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#22D3EE', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
const marker = { visible: true, isFilled: true, dataLabel: { visible: true } } as any;
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Monthly Sales Performance" tooltip={{ enable: true }} legendSettings={{ visible: true }}>
<Inject services={[ColumnSeries, Tooltip, Legend, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={SalesData} xName="Month" yName="Amount" name="Sales" type="Column" linearGradient={linearGradient} marker={marker} />
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let SalesData = [
{ Month: "Jan", Amount: 78 },
{ Month: "Feb", Amount: 88 },
{ Month: "Mar", Amount: 99 },
{ Month: "Apr", Amount: 92 },
{ Month: "May", Amount: 95 },
{ Month: "Jun", Amount: 102 },
{ Month: "Jul", Amount: 110 },
{ Month: "Aug", Amount: 105 }
];export let SalesData: Object[] = [
{ Month: "Jan", Amount: 78 },
{ Month: "Feb", Amount: 88 },
{ Month: "Mar", Amount: 99 },
{ Month: "Apr", Amount: 92 },
{ Month: "May", Amount: 95 },
{ Month: "Jun", Amount: 102 },
{ Month: "Jul", Amount: 110 },
{ Month: "Aug", Amount: 105 }
];Trendlines
Apply a linear gradient to a trendline by adding linearGradient inside the target Trendline.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category, TrendlinesDirective, TrendlineDirective } from '@syncfusion/ej2-react-charts';
import { OrdersData } from './datasource';
function App() {
const primaryXAxis = { valueType: 'Category', majorGridLines: { width: 0 } };
const primaryYAxis = { lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const trendLinearGradient = { x1: 0, y1: 0, x2: 1, y2: 0,
gradientColorStop: [
{ color: '#F97316', offset: 0, opacity: 1 },
{ color: '#4F46E5', offset: 100, opacity: 1 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Retail Orders Processed" legendSettings={{ visible: true }}>
<Inject services={[SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={OrdersData} xName="Month" yName="Orders" type="Spline" marker={{ visible: true }} name='Orders'>
<TrendlinesDirective>
<TrendlineDirective type='Linear' width={3} name='Orders Trend' linearGradient={trendLinearGradient}>
</TrendlineDirective>
</TrendlinesDirective>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, SplineSeries, LineSeries, Trendlines, Tooltip,
Legend, Category, TrendlinesDirective, TrendlineDirective
} from '@syncfusion/ej2-react-charts';
import { OrdersData } from './datasource';
function App() {
const primaryXAxis: AxisModel = { valueType: 'Category', majorGridLines: { width: 0 } };
const primaryYAxis: AxisModel = { lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const trendLinearGradient = { x1: 0, y1: 0, x2: 1, y2: 0,
gradientColorStop: [
{ color: '#F97316', offset: 0, opacity: 1 },
{ color: '#4F46E5', offset: 100, opacity: 1 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Retail Orders Processed" legendSettings={{ visible: true }} >
<Inject services={[SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={OrdersData} xName="Month" yName="Orders" type="Spline" marker={{ visible: true }} name="Orders">
<TrendlinesDirective>
<TrendlineDirective type="Linear" width={3} name="Orders Trend" linearGradient={trendLinearGradient} />
</TrendlinesDirective>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let OrdersData = [
{ Month: "Jan", Orders: 24 },
{ Month: "Feb", Orders: 30 },
{ Month: "Mar", Orders: 27 },
{ Month: "Apr", Orders: 34 },
{ Month: "May", Orders: 41 },
{ Month: "Jun", Orders: 37 },
{ Month: "Jul", Orders: 49 },
{ Month: "Aug", Orders: 45 },
{ Month: "Sep", Orders: 39 },
{ Month: "Oct", Orders: 46 },
{ Month: "Nov", Orders: 54 },
{ Month: "Dec", Orders: 52 }
];export let OrdersData: object[] = [
{ Month: "Jan", Orders: 24 },
{ Month: "Feb", Orders: 30 },
{ Month: "Mar", Orders: 27 },
{ Month: "Apr", Orders: 34 },
{ Month: "May", Orders: 41 },
{ Month: "Jun", Orders: 37 },
{ Month: "Jul", Orders: 49 },
{ Month: "Aug", Orders: 45 },
{ Month: "Sep", Orders: 39 },
{ Month: "Oct", Orders: 46 },
{ Month: "Nov", Orders: 54 },
{ Month: "Dec", Orders: 52 }
];Technical Indicators
Apply a linear gradient to a technical indicator by adding linearGradient inside the target Indicator.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, CandleSeries, LineSeries, EmaIndicator, IndicatorsDirective, IndicatorDirective, DateTime, Tooltip, Legend } from '@syncfusion/ej2-react-charts';
import { PriceSeries } from './datasource';
function App() {
const primaryXAxis = { title: 'Months', valueType: 'DateTime', intervalType: 'Months', labelFormat: 'MMM yyyy', edgeLabelPlacement: 'Shift', majorGridLines: { width: 0 } };
const primaryYAxis = { title: 'Price (USD)', labelFormat: '${value}', minimum: 90, maximum: 130, interval: 10, lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const emaGradient = { x1: 0, y1: 0, x2: 1, y2: 0,
gradientColorStop: [
{ color: '#7C3AED', offset: 0, opacity: 1 },
{ color: '#F59E0B', offset: 100, opacity: 1 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Equity Price - Jan-Nov 2025" tooltip={{ enable: true }} legendSettings={{ visible: false }} >
<Inject services={[CandleSeries, LineSeries, EmaIndicator, DateTime, Tooltip, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={PriceSeries} width={2} xName="Date" yName="y" low="Low" high="High" close="Close" volume="Volume" open="Open" name="Equity Price" type="Candle" />
</SeriesCollectionDirective>
<IndicatorsDirective>
<IndicatorDirective type="Ema" field="Close" seriesName="Equity Price" xName="Date" width={2} period={3} linearGradient={emaGradient} />
</IndicatorsDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, CandleSeries, LineSeries,
EmaIndicator, IndicatorsDirective, IndicatorDirective, DateTime, Tooltip, Legend
} from '@syncfusion/ej2-react-charts';
import { PriceSeries } from './datasource';
function App() {
const primaryXAxis: AxisModel = { title: 'Months', valueType: 'DateTime', intervalType: 'Months', labelFormat: 'MMM yyyy', edgeLabelPlacement: 'Shift', majorGridLines: { width: 0 } };
const primaryYAxis: AxisModel = { title: 'Price (USD)', labelFormat: '${value}', minimum: 90, maximum: 130, interval: 10, lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const emaGradient = { x1: 0, y1: 0, x2: 1, y2: 0,
gradientColorStop: [
{ color: '#7C3AED', offset: 0, opacity: 1 },
{ color: '#F59E0B', offset: 100, opacity: 1 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Equity Price - Jan-Nov 2025" tooltip={{ enable: true }} legendSettings={{ visible: false }} >
<Inject services={[CandleSeries, LineSeries, EmaIndicator, DateTime, Tooltip, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={PriceSeries} width={2} xName="Date" yName="y" low="Low" high="High" close="Close" volume="Volume" open="Open" name="Equity Price" type="Candle" />
</SeriesCollectionDirective>
<IndicatorsDirective>
<IndicatorDirective type="Ema" field="Close" seriesName="Equity Price" xName="Date" width={2} period={3} linearGradient={emaGradient} />
</IndicatorsDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let PriceSeries = [
{ Date: new Date(2025, 0, 1), Open: 103.9, High: 106.8, Low: 102.5, Close: 105.6, Volume: 182540000 },
{ Date: new Date(2025, 1, 1), Open: 105.2, High: 108.1, Low: 103.4, Close: 106.9, Volume: 176310000 },
{ Date: new Date(2025, 2, 1), Open: 106.7, High: 110.6, Low: 105.1, Close: 108.7, Volume: 189250000 },
{ Date: new Date(2025, 3, 1), Open: 108.9, High: 110.9, Low: 106.8, Close: 107.6, Volume: 171900000 },
{ Date: new Date(2025, 4, 1), Open: 107.8, High: 112.3, Low: 106.9, Close: 111.4, Volume: 196700000 },
{ Date: new Date(2025, 5, 1), Open: 111.2, High: 114.9, Low: 110.0, Close: 113.6, Volume: 205600000 },
{ Date: new Date(2025, 6, 1), Open: 113.5, High: 117.3, Low: 112.2, Close: 116.0, Volume: 213400000 },
{ Date: new Date(2025, 7, 1), Open: 116.1, High: 119.2, Low: 114.6, Close: 118.1, Volume: 221900000 },
{ Date: new Date(2025, 8, 1), Open: 117.9, High: 120.7, Low: 116.0, Close: 116.8, Volume: 198300000 },
{ Date: new Date(2025, 9, 1), Open: 116.7, High: 121.6, Low: 116.1, Close: 119.9, Volume: 234600000 },
{ Date: new Date(2025, 10, 1), Open: 120.2, High: 123.9, Low: 118.8, Close: 122.5, Volume: 226100000 }
];export let PriceSeries: object[] = [
{ Date: new Date(2025, 0, 1), Open: 103.9, High: 106.8, Low: 102.5, Close: 105.6, Volume: 182540000 },
{ Date: new Date(2025, 1, 1), Open: 105.2, High: 108.1, Low: 103.4, Close: 106.9, Volume: 176310000 },
{ Date: new Date(2025, 2, 1), Open: 106.7, High: 110.6, Low: 105.1, Close: 108.7, Volume: 189250000 },
{ Date: new Date(2025, 3, 1), Open: 108.9, High: 110.9, Low: 106.8, Close: 107.6, Volume: 171900000 },
{ Date: new Date(2025, 4, 1), Open: 107.8, High: 112.3, Low: 106.9, Close: 111.4, Volume: 196700000 },
{ Date: new Date(2025, 5, 1), Open: 111.2, High: 114.9, Low: 110.0, Close: 113.6, Volume: 205600000 },
{ Date: new Date(2025, 6, 1), Open: 113.5, High: 117.3, Low: 112.2, Close: 116.0, Volume: 213400000 },
{ Date: new Date(2025, 7, 1), Open: 116.1, High: 119.2, Low: 114.6, Close: 118.1, Volume: 221900000 },
{ Date: new Date(2025, 8, 1), Open: 117.9, High: 120.7, Low: 116.0, Close: 116.8, Volume: 198300000 },
{ Date: new Date(2025, 9, 1), Open: 116.7, High: 121.6, Low: 116.1, Close: 119.9, Volume: 234600000 },
{ Date: new Date(2025, 10, 1), Open: 120.2, High: 123.9, Low: 118.8, Close: 122.5, Volume: 226100000 }
];Radial gradient
A radial gradient blends colors outward from a central point, creating a circular or elliptical color progression. Configure it by adding radialGradient inside the target element (Series, Trendline, or Indicator) and define one or more color stops to control how colors transition from the center to the outer edge. Set the gradient’s center, optional focal point, and radius using radialGradient properties. The color stop values such as offset, color, opacity, lighten, and brighten are set using the gradientColorStop property.
In the radialGradient:
-
cx- Sets the normalized horizontal center of the gradient (0 to 1). -
cy- Sets the normalized vertical center of the gradient (0 to 1). -
fx- Sets the normalized horizontal focal point from which the gradient appears to originate (0 to 1). -
fy- Sets the normalized vertical focal point (0 to 1). -
r- Sets the normalized radius of the gradient circle (0 to 1).
In the gradientColorStop:
-
offset- Specifies the position of the color stop along the gradient (0 to 100). -
color- Sets the color at the stop. -
opacity- Defines the transparency of the stop (0 to 1). -
lighten- Adjusts lightness at the stop. Positive values lighten the color. Range: 0 to 1. -
brighten- Adjusts brightness at the stop. Positive values increase brightness; negative values decrease it. Ranges: -1 to 1.
Series
Apply a radial gradient to a series by adding radialGradient inside the target Series. The same gradient is applied to the series markers, legend symbol and tooltip marker for visual consistency.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Tooltip, Legend, Category, DataLabel } from '@syncfusion/ej2-react-charts';
import { SalesData } from './datasource';
function App() {
const primaryXAxis = { valueType: 'Category' };
const primaryYAxis = { labelFormat: '${value}k' };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
const marker = { visible: true, isFilled: true, dataLabel: { visible: true } };
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Monthly Sales Performance" tooltip={{ enable: true }} legendSettings={{ visible: true }}>
<Inject services={[ColumnSeries, Tooltip, Legend, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={SalesData} xName="Month" yName="Amount" name="Sales" type="Column" radialGradient={radialGradient} marker={marker} />
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Tooltip, Legend, Category, DataLabel } from '@syncfusion/ej2-react-charts';
import { SalesData } from './datasource';
function App() {
const primaryXAxis: AxisModel = { valueType: 'Category' };
const primaryYAxis: AxisModel = { labelFormat: '${value}k' };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
const marker = { visible: true, isFilled: true, dataLabel: { visible: true } };
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Monthly Sales Performance" tooltip={{ enable: true }} legendSettings={{ visible: true }}>
<Inject services={[ColumnSeries, Tooltip, Legend, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={SalesData} xName="Month" yName="Amount" name="Sales" type="Column" radialGradient={radialGradient} marker={marker} />
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let SalesData = [
{ Month: "Jan", Amount: 78 },
{ Month: "Feb", Amount: 88 },
{ Month: "Mar", Amount: 99 },
{ Month: "Apr", Amount: 92 },
{ Month: "May", Amount: 95 },
{ Month: "Jun", Amount: 102 },
{ Month: "Jul", Amount: 110 },
{ Month: "Aug", Amount: 105 }
];export let SalesData: object[] = [
{ Month: "Jan", Amount: 78 },
{ Month: "Feb", Amount: 88 },
{ Month: "Mar", Amount: 99 },
{ Month: "Apr", Amount: 92 },
{ Month: "May", Amount: 95 },
{ Month: "Jun", Amount: 102 },
{ Month: "Jul", Amount: 110 },
{ Month: "Aug", Amount: 105 }
];Trendlines
Apply a linear gradient to a trendline by adding linearGradient inside the target Trendline.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category, TrendlinesDirective, TrendlineDirective } from '@syncfusion/ej2-react-charts';
import { OrdersData } from './datasource';
function App() {
const primaryXAxis = { valueType: 'Category', majorGridLines: { width: 0 } };
const primaryYAxis = { lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Retail Orders Processed" legendSettings={{ visible: true }}>
<Inject services={[SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={OrdersData} xName="Month" yName="Orders" type="Spline" marker={{ visible: true }} name='Orders'>
<TrendlinesDirective>
<TrendlineDirective type='Linear' width={3} name='Orders Trend' radialGradient={radialGradient}>
</TrendlineDirective>
</TrendlinesDirective>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, SplineSeries, LineSeries, Trendlines, Tooltip,
Legend, Category, TrendlinesDirective, TrendlineDirective
} from '@syncfusion/ej2-react-charts';
import { OrdersData } from './datasource';
function App() {
const primaryXAxis: AxisModel = { valueType: 'Category', majorGridLines: { width: 0 } };
const primaryYAxis: AxisModel = { lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Retail Orders Processed" legendSettings={{ visible: true }} >
<Inject services={[SplineSeries, LineSeries, Trendlines, Tooltip, Legend, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={OrdersData} xName="Month" yName="Orders" type="Spline" marker={{ visible: true }} name="Orders">
<TrendlinesDirective>
<TrendlineDirective type="Linear" width={3} name="Orders Trend" radialGradient={radialGradient} />
</TrendlinesDirective>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let OrdersData = [
{ Month: "Jan", Orders: 24 },
{ Month: "Feb", Orders: 30 },
{ Month: "Mar", Orders: 27 },
{ Month: "Apr", Orders: 34 },
{ Month: "May", Orders: 41 },
{ Month: "Jun", Orders: 37 },
{ Month: "Jul", Orders: 49 },
{ Month: "Aug", Orders: 45 },
{ Month: "Sep", Orders: 39 },
{ Month: "Oct", Orders: 46 },
{ Month: "Nov", Orders: 54 },
{ Month: "Dec", Orders: 52 }
];export let OrdersData: object[] = [
{ Month: "Jan", Orders: 24 },
{ Month: "Feb", Orders: 30 },
{ Month: "Mar", Orders: 27 },
{ Month: "Apr", Orders: 34 },
{ Month: "May", Orders: 41 },
{ Month: "Jun", Orders: 37 },
{ Month: "Jul", Orders: 49 },
{ Month: "Aug", Orders: 45 },
{ Month: "Sep", Orders: 39 },
{ Month: "Oct", Orders: 46 },
{ Month: "Nov", Orders: 54 },
{ Month: "Dec", Orders: 52 }
];Technical Indicators
Apply a linear gradient to a technical indicator by adding linearGradient inside the target Indicator.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, CandleSeries, LineSeries, EmaIndicator, IndicatorsDirective, IndicatorDirective, DateTime, Tooltip, Legend } from '@syncfusion/ej2-react-charts';
import { PriceSeries } from './datasource';
function App() {
const primaryXAxis = { title: 'Months', valueType: 'DateTime', intervalType: 'Months', labelFormat: 'MMM yyyy', edgeLabelPlacement: 'Shift', majorGridLines: { width: 0 } };
const primaryYAxis = { title: 'Price (USD)', labelFormat: '${value}', minimum: 90, maximum: 130, interval: 10, lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Equity Price - Jan-Nov 2025" tooltip={{ enable: true }} legendSettings={{ visible: false }} >
<Inject services={[CandleSeries, LineSeries, EmaIndicator, DateTime, Tooltip, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={PriceSeries} width={2} xName="Date" yName="y" low="Low" high="High" close="Close" volume="Volume" open="Open" name="Equity Price" type="Candle" />
</SeriesCollectionDirective>
<IndicatorsDirective>
<IndicatorDirective type="Ema" field="Close" seriesName="Equity Price" xName="Date" width={2} period={3} radialGradient={radialGradient} />
</IndicatorsDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, CandleSeries, LineSeries,
EmaIndicator, IndicatorsDirective, IndicatorDirective, DateTime, Tooltip, Legend
} from '@syncfusion/ej2-react-charts';
import { PriceSeries } from './datasource';
function App() {
const primaryXAxis: AxisModel = { title: 'Months', valueType: 'DateTime', intervalType: 'Months', labelFormat: 'MMM yyyy', edgeLabelPlacement: 'Shift', majorGridLines: { width: 0 } };
const primaryYAxis: AxisModel = { title: 'Price (USD)', labelFormat: '${value}', minimum: 90, maximum: 130, interval: 10, lineStyle: { width: 0 }, majorTickLines: { width: 0 } };
const radialGradient = {
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5, r: 0.5,
gradientColorStop: [
{ color: '#FFFF00', offset: 0, opacity: 1, lighten: 0, brighten: 0 },
{ color: '#7C3AED', offset: 100, opacity: 0.95, lighten: 0, brighten: 0.9 }
]
};
return (
<ChartComponent id="charts" primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title="Equity Price - Jan-Nov 2025" tooltip={{ enable: true }} legendSettings={{ visible: false }} >
<Inject services={[CandleSeries, LineSeries, EmaIndicator, DateTime, Tooltip, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={PriceSeries} width={2} xName="Date" yName="y" low="Low" high="High" close="Close" volume="Volume" open="Open" name="Equity Price" type="Candle" />
</SeriesCollectionDirective>
<IndicatorsDirective>
<IndicatorDirective type="Ema" field="Close" seriesName="Equity Price" xName="Date" width={2} period={3} radialGradient={radialGradient} />
</IndicatorsDirective>
</ChartComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));export let PriceSeries = [
{ Date: new Date(2025, 0, 1), Open: 103.9, High: 106.8, Low: 102.5, Close: 105.6, Volume: 182540000 },
{ Date: new Date(2025, 1, 1), Open: 105.2, High: 108.1, Low: 103.4, Close: 106.9, Volume: 176310000 },
{ Date: new Date(2025, 2, 1), Open: 106.7, High: 110.6, Low: 105.1, Close: 108.7, Volume: 189250000 },
{ Date: new Date(2025, 3, 1), Open: 108.9, High: 110.9, Low: 106.8, Close: 107.6, Volume: 171900000 },
{ Date: new Date(2025, 4, 1), Open: 107.8, High: 112.3, Low: 106.9, Close: 111.4, Volume: 196700000 },
{ Date: new Date(2025, 5, 1), Open: 111.2, High: 114.9, Low: 110.0, Close: 113.6, Volume: 205600000 },
{ Date: new Date(2025, 6, 1), Open: 113.5, High: 117.3, Low: 112.2, Close: 116.0, Volume: 213400000 },
{ Date: new Date(2025, 7, 1), Open: 116.1, High: 119.2, Low: 114.6, Close: 118.1, Volume: 221900000 },
{ Date: new Date(2025, 8, 1), Open: 117.9, High: 120.7, Low: 116.0, Close: 116.8, Volume: 198300000 },
{ Date: new Date(2025, 9, 1), Open: 116.7, High: 121.6, Low: 116.1, Close: 119.9, Volume: 234600000 },
{ Date: new Date(2025, 10, 1), Open: 120.2, High: 123.9, Low: 118.8, Close: 122.5, Volume: 226100000 }
];export let PriceSeries: object[] = [
{ Date: new Date(2025, 0, 1), Open: 103.9, High: 106.8, Low: 102.5, Close: 105.6, Volume: 182540000 },
{ Date: new Date(2025, 1, 1), Open: 105.2, High: 108.1, Low: 103.4, Close: 106.9, Volume: 176310000 },
{ Date: new Date(2025, 2, 1), Open: 106.7, High: 110.6, Low: 105.1, Close: 108.7, Volume: 189250000 },
{ Date: new Date(2025, 3, 1), Open: 108.9, High: 110.9, Low: 106.8, Close: 107.6, Volume: 171900000 },
{ Date: new Date(2025, 4, 1), Open: 107.8, High: 112.3, Low: 106.9, Close: 111.4, Volume: 196700000 },
{ Date: new Date(2025, 5, 1), Open: 111.2, High: 114.9, Low: 110.0, Close: 113.6, Volume: 205600000 },
{ Date: new Date(2025, 6, 1), Open: 113.5, High: 117.3, Low: 112.2, Close: 116.0, Volume: 213400000 },
{ Date: new Date(2025, 7, 1), Open: 116.1, High: 119.2, Low: 114.6, Close: 118.1, Volume: 221900000 },
{ Date: new Date(2025, 8, 1), Open: 117.9, High: 120.7, Low: 116.0, Close: 116.8, Volume: 198300000 },
{ Date: new Date(2025, 9, 1), Open: 116.7, High: 121.6, Low: 116.1, Close: 119.9, Volume: 234600000 },
{ Date: new Date(2025, 10, 1), Open: 120.2, High: 123.9, Low: 118.8, Close: 122.5, Volume: 226100000 }
];