CloudCharts for React dashboards: from series data to a bar chart
开箱即用的前端图表库,简单配置就能拥有漂亮的可视化图表
At a glance
- What is it?
- CloudCharts packages common chart configurations as React components over AntV G2. The bar component offers a short path from named series to a dashboard widget, with a React peer range that matters when upgrading an existing application.
- Who is it for?
- CloudCharts fits a React dashboard that can express its views through the supplied chart components. Teams on newer React versions should first verify the package's declared peer range against their application.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 114 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 20, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Where the React components fit
Alibaba's [CloudCharts README](https://github.com/alibaba/cloud-charts/blob/45cf17acd7bad3090d105ca727e07e7a1191cab0/README.md) presents the library for administrative interfaces that repeat charts across screens. A widget built with the provided components can concentrate on supplying its data and chart options. The repository's [package manifest](https://github.com/alibaba/cloud-charts/blob/45cf17acd7bad3090d105ca727e07e7a1191cab0/package.json) declares AntV G2 as a dependency, which places the React chart interface above the graphics engine.
Install CloudCharts and draw the first bar chart
In an existing React application, use the README's npm command. It adds the CloudCharts package to the application dependencies.
npm install @alicloud/cloud-charts --saveThe README imports Wcontainer and Wbar. The example below reduces the dataset to two observations per series, one per month. Wbar receives the named series and the legend configuration as separate props. The rendered view is intended to show two series for January and February with a right-aligned legend.
import { Wcontainer, Wbar } from '@alicloud/cloud-charts';
const data = [
{ name: 'Orders', data: [['Jan', 59], ['Feb', 23]] },
{ name: 'Returns', data: [['Jan', 4], ['Feb', 7]] },
];
const options = { legend: { align: 'right' } };
export function Demo() {
return (
<Wcontainer className="demos">
<Wbar height="400" config={options} data={data} />
</Wcontainer>
);
}An application that starts with row-shaped API results can group observations by metric and map each group to the category-value pairs this component expects. Keep that conversion next to the widget so the mapping between an API field and a visual series is easy to find.
Validate the data where the widget consumes it
A dashboard that joins orders and returns often receives values from different queries. Establish one vocabulary for the horizontal axis before creating either series. For a quarterly dashboard that uses month labels, for example, generate the three labels in reporting order and build the two series against that list. Otherwise two queries may return different orders, or one may omit a month entirely. An absent aggregate can mean the query did not return a value. Preserve that distinction from a genuine zero until the reporting team chooses what to display.
Keep the mapping independent of the chart component so it has an inexpensive unit test. Feed the mapper one month's rows for each metric and assert the output names and pairs. Then add a fixture where an API accidentally returns a formatted string such as “1,200” in a numeric field. Validate it according to the API contract before it becomes a chart value. The README passes plain numbers in the pairs, so formatting belongs at the display boundary. You can catch a surprising amount here by asserting that labels occur in the intended order and that each series name corresponds to the metric used to calculate its values.
Choose metrics that can share a scale. Orders and returns are both counts in the example. Pairing an order count with a return percentage would obscure their units and invite readers to compare bar heights directly. Store the unit alongside the metric definition in the dashboard and use it to choose an appropriate widget and heading.
Check the widget in its dashboard layout
The README example supplies a height of 400 and asks for a right-aligned legend. Try that configuration first in the same card where the chart will ship. A chart tested only in a full-width sandbox may have room for a legend and labels that a dashboard's two-column layout lacks. Start with the two short series names in the example so you can verify the connection between the data and its legend. Then render the labels and locale you intend to ship. Try the narrower card width, a long metric name, and the case where a report is loading or returns no observations.
Keep loading and empty states in the surrounding dashboard component. That lets operators distinguish a pending query from a completed report with no observations before inspecting the chart. For an administrative view, consider putting the same counts in a small table alongside or below the chart. The graphic lets readers scan patterns, and the table gives them exact values for a month when they need to reconcile a discrepancy.
A short integration check should cover both the initial report and a filter change. Use two small fixtures with different values for the same month, update the dashboard filter, and verify that the chart and accompanying labels reflect the new fixture together. Run the check in the application's installed React environment. The upstream example establishes the input shape and configuration, while the application check verifies behavior in the dependency tree and layout you actually use.
React compatibility and the direct G2 alternative
The [published npm metadata](https://registry.npmjs.org/@alicloud%2fcloud-charts/latest) identifies version 1.1.31 at review and declares React and React DOM peer ranges of `15.6 || 16 || 17`. React upgrades should be evaluated against those declared peers before adding the widget. A team building a custom graphic can use [AntV G2](https://github.com/antvis/G2) directly, expressing marks and encodings with the engine's own API. That gives the application more responsibility for the chart definition and integration. CloudCharts is distributed under the [MIT license](https://github.com/alibaba/cloud-charts/blob/45cf17acd7bad3090d105ca727e07e7a1191cab0/LICENSE), which requires retaining the copyright and permission notice with copies or substantial portions of the software.
Editorial conclusion
CloudCharts fits a React dashboard that can express its views through the supplied chart components. Teams on newer React versions should first verify the package's declared peer range against their application. For a dashboard with custom marks and encodings, the chart abstraction to evaluate first is G2 itself.
Frequently asked questions
Which npm package installs CloudCharts?
The documented package is @alicloud/cloud-charts.
How does CloudCharts express multiple bar series?
The README passes Wbar an array of series objects. Each supplies a name and a data array of category-value pairs.
Which React versions does CloudCharts declare as peers?
The inspected npm release declares the peer range 15.6 || 16 || 17 for both React and React DOM.