
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
echarts-react-wrapper
Advanced tools
React component of Echarts. It requires ECharts version 5.x. The development is done with React 18.
npm -i echarts react echarts-react-wrapper
It requires peer two dependencies, react and echarts. I use React 18 and Echarts 5.6 for testing this component.
import { EchartsComponent } from 'echarts-react-wrapper'
export function ChartContainer() {
return <EchartsComponent
style={{
width: 500,
height: 500
}}
options={{
yAxis={
type: "value"
},
xAxis={
type: "category",
data: [0, 1, 2, 3]
}
series=[{
type: "line",
data: [1, 2, 3, 4]
}]
}}
eventsHandler={{
click: (params, context) => {
console.log(params, context)
}
}}
/>
}
params and context as it arguments. For more details, see this tutorialUse onInit callback to obtains Echarts instance. After that, you can follow this tutorial to fire an action/event.
This component support option as an object and merging strategy that Echarts 5 provide.
For example, replaceMerge: true will allow user to remove an entry from existing option that Echarts is using.
If original option look like this:
import { EchartsComponent } from 'echarts-react-wrapper'
export function ChartContainer({option}) {
return <EchartsComponent
style={{
width: 500,
height: 500
}}
option={option}
eventsHandler={{
click: (params, context) => {
console.log(params, context)
}
}}
replaceMerge={["series"]}
/>
}
When first render, option is
{
yAxis={
type: "value"
},
xAxis={
type: "category",
data: [0, 1, 2, 3]
}
series=[{
id: "data1",
type: "line",
data: [1, 2, 3, 4]
}]
}
Then sometime later, option is
{
yAxis={
type: "value"
},
xAxis={
type: "category",
data: [0, 1, 2, 3]
}
series=[{
id: "data2",
type: "line",
data: [4, 3, 2, 1]
}]
}
The chart will remove series with id "data1" out and put series with id "data2" in place.
There's a use case where each update to option may need complex logic. It's possible to obtain echarts instance without any option supplied. For example:
import { EchartsComponent } from 'echarts-react-wrapper'
export function ChartContainer({/* list of props that may involve option logic */}) {
const [echarts, setEcharts] = useState()
if (echarts !== undefined) {
// perform some complex logic to generate option
echarts.setOption(/* option obtain from logic above */, {replaceMerge: [/* field to be modify */]})
}
return <EchartsComponent
style={{
width: 500,
height: 500
}}
onInit={instance => setEcharts(instance)}
eventsHandler={{
click: (params, context) => {
console.log(params, context)
}
}}
/>
}
This usage style may be much more efficient if it involve constructing large and complex data or dataset for chart.
FAQs
Echarts wrap as React component
We found that echarts-react-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.