Bubble Chart in React Chart
20 Aug 202624 minutes to read
Bubble
To render a bubble series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
typeasBubblein your chart configuration. This indicates that the data should be displayed as a bubble series in the chart. -
Inject the BubbleSeries module: Inject
BubbleSeriesmodule into theservices. This step is essential, as it ensures that the necessary functionalities for rendering the bubble series are available in your chart.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];Binding data with series
You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName and yName properties.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];Series customization
The following properties can be used to customize the bubble series.
Fill
The fill property determines the color applied to the series.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound' fill='blue'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' fill='blue'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];Opacity
The opacity property controls the transparency of the fill and affects how the series blends with background or overlapping series. For example, opacity={0.5} makes each bubble semi-transparent.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];Size mapping
Use the size property to map the size of each bubble to a numeric field in the data source. For example, size='size' maps a numeric field from the data source to the bubble size, allowing relative comparison between data points.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { bubbleData } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={bubbleData} xName='x' yName='y' size='size' type='Bubble'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { bubbleData } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[BubbleSeries]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={bubbleData} xName='x' yName='y' size='size' type='Bubble'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let bubbleData = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];export let bubbleData: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347, text: 'China' },
{ x: 74, y: 6.5, size: 1.241, text: 'India' },
{ x: 90.4, y: 6.0, size: 0.238, text: 'Indonesia' },
{ x: 99.4, y: 2.2, size: 0.312, text: 'US' },
{ x: 88.6, y: 1.3, size: 0.197, text: 'Brazil' },
{ x: 99, y: 0.7, size: 0.0818, text: 'Germany' },
{ x: 72, y: 2.0, size: 0.0826, text: 'Egypt' },
{ x: 99.6, y: 3.4, size: 0.143, text: 'Russia' },
{ x: 99, y: 0.2, size: 0.128, text: 'Japan' },
{ x: 86.1, y: 4.0, size: 0.115, text: 'Mexico' },
{ x: 92.6, y: 6.6, size: 0.096, text: 'Philippines' },
{ x: 61.3, y: 14.5, size: 0.162, text: 'Nigeria' }
];Empty points
Data points with null or undefined values are considered empty. Empty data points are not plotted on the chart.
Mode
Use the mode property of emptyPointSettings to control how empty points are rendered. Available modes are Gap (leave a break, the default), Drop (Ignores the empty point during rendering), Zero (plot as zero), and Average (plot as the average of neighboring points).
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
const emptyPoint = {
mode: 'Gap',
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
const emptyPoint: object = {
mode: 'Gap',
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];Fill
Use the fill property of emptyPointSettings to set the fill color for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
const emptyPoint = {
mode: 'Zero', fill: 'red'
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
const emptyPoint: object = {
mode: 'Zero', fill: 'red'
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];Border
Use the border property of emptyPointSettings to customize the border width and color for empty points, for example
border={{ width: 1.5, color: 'green' }}
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
const emptyPoint = {
mode: 'Zero', fill: 'red', border: {width: 1.5, color:'green'}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
const emptyPoint: object = {
mode: 'Zero', fill: 'red', border: {width: 1.5, color:'green'}
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: null, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: undefined, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];Events
Series render
The seriesRender event fires before each series is rendered. Use its event arguments to modify the series data, fill, or name dynamically before rendering.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
const seriesRender = (args) => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} seriesRender={seriesRender} title='GDP vs Literacy Rate'>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel, ISeriesRenderEventArgs } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries }
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
import type { EmitType } from '@syncfusion/ej2-base';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
const seriesRender: EmitType<ISeriesRenderEventArgs> = (args: ISeriesRenderEventArgs): void => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate'
seriesRender={seriesRender}>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound' seriesRender={seriesRender}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: 7, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: 4, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: 7, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: 4, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];Point render
The pointRender event fires for each data point before it is drawn. Use its event arguments to customize the appearance of individual points before they are rendered.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, BubbleSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 };
const primaryyAxis = { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 };
const pointRender = (args) => {
if (args.point.y < 7.5) {
args.fill = '#ff6347';
} else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='GDP vs Literacy Rate' pointRender={pointRender}>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel, IPointRenderEventArgs } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
BubbleSeries }
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
import type { EmitType } from '@syncfusion/ej2-base';
function App() {
const primaryxAxis: AxisModel= { title: 'Literacy Rate', minimum: 60, maximum: 100, interval: 5 } ;
const primaryyAxis: AxisModel= { title: 'GDP growth rate', minimum: -2, maximum: 16, interval: 2 } ;
const pointRender: EmitType<IPointRenderEventArgs> = (args: IPointRenderEventArgs): void => {
if (args.point.y < 7.5) {
args.fill = '#ff6347';
} else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
title='GDP vs Literacy Rate' pointRender={pointRender}>
<Inject services={[BubbleSeries]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource ={data} xName='x' yName='y' size='size' type='Bubble' name='pound'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let data = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: 7, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: 4, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];export let data: Object[] = [
{ x: 92.2, y: 7.8, size: 1.347 },
{ x: 74, y: 6.5, size: 1.241 },
{ x: 90.4, y: 7, size: 0.238 },
{ x: 99.4, y: 2.2, size: 0.312 },
{ x: 88.6, y: 1.3, size: 0.197 },
{ x: 99, y: 0.7, size: 0.0818 },
{ x: 72, y: 2.0, size: 0.0826 },
{ x: 99.6, y: 3.4, size: 0.143 },
{ x: 99, y: 4, size: 0.128 },
{ x: 86.1, y: 4.0, size: 0.115 },
{ x: 92.6, y: 6.6, size: 0.096 },
{ x: 61.3, y: 14.5, size: 0.162 },
];