
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@elastic/charts
Advanced tools
@elastic/charts is a powerful charting library developed by Elastic. It provides a wide range of chart types and is designed to be highly customizable and performant. It is particularly well-suited for creating complex, data-driven visualizations in web applications.
Line Chart
This code sample demonstrates how to create a simple line chart using @elastic/charts. The LineSeries component is used to define the data and the axes for the chart.
import { Chart, LineSeries, Settings } from '@elastic/charts';
const data = [
{ x: 0, y: 2 },
{ x: 1, y: 3 },
{ x: 2, y: 5 },
{ x: 3, y: 7 },
];
const LineChart = () => (
<Chart>
<Settings showLegend={true} legendPosition="right" />
<LineSeries
id="lineSeries"
xScaleType="linear"
yScaleType="linear"
xAccessor="x"
yAccessor="y"
data={data}
/>
</Chart>
);
Bar Chart
This code sample demonstrates how to create a bar chart using @elastic/charts. The BarSeries component is used to define the data and the axes for the chart.
import { Chart, BarSeries, Settings } from '@elastic/charts';
const data = [
{ x: 'A', y: 30 },
{ x: 'B', y: 80 },
{ x: 'C', y: 45 },
{ x: 'D', y: 60 },
];
const BarChart = () => (
<Chart>
<Settings showLegend={true} legendPosition="right" />
<BarSeries
id="barSeries"
xScaleType="ordinal"
yScaleType="linear"
xAccessor="x"
yAccessor="y"
data={data}
/>
</Chart>
);
Pie Chart
This code sample demonstrates how to create a pie chart using @elastic/charts. The Partition component is used to define the data and the structure of the pie chart.
import { Chart, Partition, Settings } from '@elastic/charts';
const data = [
{ category: 'A', value: 30 },
{ category: 'B', value: 80 },
{ category: 'C', value: 45 },
{ category: 'D', value: 60 },
];
const PieChart = () => (
<Chart>
<Settings showLegend={true} legendPosition="right" />
<Partition
id="pieChart"
data={data}
valueAccessor={(d) => d.value}
valueFormatter={(d) => `${d} %`}
layers={[
{
groupByRollup: (d) => d.category,
shape: {
fillColor: (d) => d.category === 'A' ? 'red' : 'blue',
},
},
]}
/>
</Chart>
);
Recharts is a composable charting library built on React components. It is easy to use and provides a wide range of chart types. Compared to @elastic/charts, Recharts is more beginner-friendly but may lack some of the advanced customization options.
Victory is another React-based charting library that offers a variety of chart types and is highly customizable. It is similar to @elastic/charts in terms of flexibility and customization but has a different API and design philosophy.
Nivo provides a rich set of dataviz components, built on top of D3 and React. It offers a wide range of chart types and is known for its beautiful and responsive charts. Nivo is comparable to @elastic/charts in terms of visual appeal and functionality.
Check out our living style guide, which contains many examples on how charts look and feel, and how to use them in your products or fork the codesandbox example here to play directly with the library.
To install the Elastic Charts into an existing project, use the yarn
CLI (npm
is not supported).
yarn add @elastic/charts
Important: see the consuming wiki for detailed installation requirements
We depend upon the version of node defined in .nvmrc.
You will probably want to install a node version manager. nvm is recommended.
To install and use the correct node version with nvm
:
nvm install
You can run the dev environment locally at http://localhost:9001 by running:
yarn
yarn start
We use storybook to document API, edge-cases, and the usage of the library. A hosted version is available at https://elastic.github.io/elastic-charts.
The primary goal of this library is to provide reusable set of chart components that can be used throughout Elastic's web products. As a single source of truth, the framework allows our designers to make changes to our look-and-feel directly in the code. And unit test coverage for the charts components allows us to deliver a stable "API for charts".
You can find documentation around creating and submitting new features in contributing.
Dual-licensed under Elastic v2 and Server Side Public License, v 1 Read the FAQ for details.
FAQs
Elastic-Charts data visualization library
The npm package @elastic/charts receives a total of 134,977 weekly downloads. As such, @elastic/charts popularity was classified as popular.
We found that @elastic/charts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 67 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.