How can I help you?
Getting started with React Bullet Chart component
28 Feb 202620 minutes to read
This section describes the steps to create a simple Bullet Chart and demonstrates the basic usage of the Bullet Chart component.
Dependencies
Below is the list of minimum dependencies required to use the Bullet Chart component.
|-- @syncfusion/ej2-react-charts
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-data
|-- @syncfusion/ej2-charts
|-- @syncfusion/ej2-react-base
|-- @syncfusion/ej2-pdf-export
|-- @syncfusion/ej2-file-utils
|-- @syncfusion/ej2-compression
|-- @syncfusion/ej2-svg-base
Installation and configuration
To easily set up a React application, use the Vite CLI (npm create vite), which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-appinstead, refer to this documentation for more details.
To create a new React application, run the following command.
npm create vite@latest my-appThis command will prompt you for a few settings for the new project, such as selecting a framework and a variant.

To set up a React application in TypeScript environment, run the following command.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm run devTo set up a React application in JavaScript environment, run the following command.
npm create vite@latest my-app -- --template react
cd my-app
npm run devInstall Syncfusion® Bullet Chart Package
All the available Essential® JS 2 packages are published in the npmjs.com public registry.
To install the Syncfusion® Bullet Chart package, use the following command
npm install @syncfusion/ej2-react-charts --saveThe –save will instruct NPM to include the Bullet Chart package inside of the dependencies section of the package.json.
Add Bullet Chart to the project
Add the Bullet Chart component to src/App.tsx using the following code.
import { BulletChartComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <BulletChartComponent />;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);import { BulletChartComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <BulletChartComponent />;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);Now run the npm run dev command in the console to start the development server. This command compiles your code and serves the application locally, opening it in the browser.
npm run dev
The below example shows a basic Bullet Chart.
import { BulletChartComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <BulletChartComponent id="bulletChart" />;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { BulletChartComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <BulletChartComponent id="bulletChart" />;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Module injection
Bullet Chart component are segregated into individual feature-wise modules. In order to use a particular feature, you need to inject its feature service in the AppModule. In the current application, we are going to use tooltip feature of the chart.
-
BulletTooltip- Inject this module in toservicesto use tooltip feature.
Import the above-mentioned module from the chart package and inject them into the services section of the Bullet Chart component as follows.
import { BulletChartComponent, BulletTooltip, Inject } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (
<BulletChartComponent id="bulletChart">
<Inject services={[BulletTooltip]} />
</BulletChartComponent>
);
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);import { BulletChartComponent, BulletTooltip, Inject } from "@syncfusion/ej2-react-charts";
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id="bulletChart">
<Inject services={[BulletTooltip]}/>
</BulletChartComponent>);
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);Bullet Chart with data
This section explains how to plot the following JSON data to the Bullet Chart.
const data = [
{ value: 100, target: 80 },
{ value: 200, target: 180 },
{ value: 300, target: 280 },
{ value: 400, target: 380 },
{ value: 500, target: 480 }
];interface DataPoint {
value: number;
target: number;
}
const data: DataPoint[] = [
{ value: 100, target: 80 },
{ value: 200, target: 180 },
{ value: 300, target: 280 },
{ value: 400, target: 380 },
{ value: 500, target: 480 }
];Now assign the local data to dataSource property. value and target values should be mapped with valueField and targetField respectively.
import { BulletChartComponent } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ value: 100, target: 80 },
{ value: 200, target: 180 },
{ value: 300, target: 280 },
{ value: 400, target: 380 },
{ value: 500, target: 480 },
];
return (<BulletChartComponent id='Revenue' style={{ textAlign: "center" }} animation={{ enable: false }} valueField='value' targetField='target' minimum={0} maximum={500} interval={50} dataSource={data}>
</BulletChartComponent>);
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { BulletChartComponent, Inject} from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data: any[] = [
{ value: 100, target: 80 },
{ value: 200, target: 180 },
{ value: 300, target: 280 },
{ value: 400, target: 380 },
{ value: 500, target: 480 },
];
return (<BulletChartComponent id='Revenue'
style={{ textAlign: "center" }}
animation={{ enable: false }}
valueField='value'
targetField='target'
minimum={0}
maximum={500}
interval={50}
dataSource={data}>
</BulletChartComponent>);
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Add Bullet Chart title
You can add a title using the title property to the Bullet Chart to provide quick information to the user about the data plotted in the Bullet Chart.
import { BulletChartComponent } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='title' style={{ textAlign: "center" }} animation={{ enable: false }} valueField='value' targetField='target' title='Revenue' minimum={0} maximum={300} interval={50} dataSource={[{ value: 270, target: 250 }]}>
</BulletChartComponent>);
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { BulletChartComponent, Inject } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='title'
style={{ textAlign: "center" }}
animation={{ enable: false }}
valueField='value'
targetField='target'
title='Revenue'
minimum={0}
maximum={300}
interval={50}
dataSource={[{ value: 270, target: 250 }]}>
</BulletChartComponent>);
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Ranges
You can add ranges to the Bullet Chart using the BulletRangeCollectionDirective and BulletRangeDirective components, which should be imported from the @syncfusion/ej2-react-charts package. Ranges provide visual context by dividing the chart into qualitative bands (e.g., poor, satisfactory, good).
import { BulletChartComponent } from '@syncfusion/ej2-react-charts';
import { BulletRangeCollectionDirective, BulletRangeDirective } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='ranges' style={{ textAlign: "center" }} animation={{ enable: false }} valueField='value' targetField='target' title='Revenue' minimum={0} maximum={300} interval={50} dataSource={[{ value: 270, target: 250 }]}>
<BulletRangeCollectionDirective>
<BulletRangeDirective end={100} color='red'></BulletRangeDirective>
<BulletRangeDirective end={200} color='blue'></BulletRangeDirective>
<BulletRangeDirective end={300} color='green'></BulletRangeDirective>
</BulletRangeCollectionDirective>
</BulletChartComponent>);
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { BulletChartComponent, Inject } from '@syncfusion/ej2-react-charts';
import { BulletRangeCollectionDirective, BulletRangeDirective } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='ranges'
style={{ textAlign: "center" }}
animation={{ enable: false }}
valueField='value'
targetField='target'
title='Revenue'
minimum={0}
maximum={300}
interval={50}
dataSource={[{ value: 270, target: 250 }]}>
<BulletRangeCollectionDirective>
<BulletRangeDirective end={100} color='red' ></BulletRangeDirective>
<BulletRangeDirective end={200} color='blue'></BulletRangeDirective>
<BulletRangeDirective end={300} color='green'></BulletRangeDirective>
</BulletRangeCollectionDirective>
</BulletChartComponent>);
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Tooltip
You can use tooltip for the Bullet Chart by setting the enable property to true in tooltip object and by injecting the BulletTooltip module into the services.
import { BulletChartComponent, Inject } from '@syncfusion/ej2-react-charts';
import { BulletTooltip } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='tooltip' style={{ textAlign: "center" }} animation={{ enable: false }} tooltip={{ enable: true }} valueField='value' targetField='target' title='Revenue' minimum={0} maximum={300} interval={50} dataSource={[{ value: 270, target: 250 }]}>
<Inject services={[BulletTooltip]} />
</BulletChartComponent>);
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { BulletChartComponent, Inject } from '@syncfusion/ej2-react-charts';
import { BulletTooltip } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return (<BulletChartComponent id='tooltip'
style={{ textAlign: "center" }}
animation={{ enable: false }}
tooltip={{ enable: true }}
valueField='value'
targetField='target'
title='Revenue'
minimum={0}
maximum={300}
interval={50}
dataSource={[{ value: 270, target: 250 }]}>
<Inject services={[BulletTooltip]} />
</BulletChartComponent>);
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);