veritatisquam
Version:
Carbon charting components, lerna monorepo
148 lines (115 loc) • 3.63 kB
text/typescript
import marked from 'marked';
export const vanillaTutorial = {
name: 'vanilla',
type: 'getting-started',
content: marked(`
The Carbon Charts vanilla library provides a collection of reusable charting components
to build websites and user interfaces. Adopting the library enables developers to use
consistent markup, styles, and behavior in prototype and production work.
**with yarn:**
\`\`\`bash
yarn add @carbon/charts d3@5.x
\`\`\`
**with npm:**
\`\`\`bash
npm install --save @carbon/charts d3@5.x
\`\`\`
**Note:** you'd also need to install \`carbon-components\` if you're not using a bundled version of the library.
To start using the \`StackedBarChart\` component, try the example below:
\`\`\`html
...
<div id="my-bar-chart"></div>
...
\`\`\`
\`\`\`js
import "@carbon/charts/styles.css";
import { StackedBarChart } from "@carbon/charts";
// grab chart holder DOM element
const chartHolder = document.getElementById("my-bar-chart");
// initialize the chart
new StackedBarChart(chartHolder, {
data: stackedBarData,
options: stackedBarOptions,
});
\`\`\`
\`\`\`html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/@carbon/charts/styles.css" />
</head>
<body>
<div id="my-bar-chart"></div>
<script src="https://unpkg.com/@carbon/charts/bundle.js"></script>
<script>
// grab chart holder DOM element
const chartHolder = document.getElementById("my-bar-chart");
const stackedBarData = [
// refer to tabular data format tutorial
];
const stackedBarOptions = {
// refer to chart specific options
};
// initialize the chart
new Charts.StackedBarChart(chartHolder, {
data: stackedBarData,
options: stackedBarOptions,
});
</script>
</body>
</html>
\`\`\`
Data follows the same model in all charts.
See tutorial on tabular data format for more information on chart data.
You can see the options for all charts
[](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/src/configuration.ts).
+ **[Demos - Data & options used](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/demo/data)**
Please refer to the
[](https://www.carbondesignsystem.com/data-visualization/chart-types)
on using the different charts available in this library.
Please refer to the
[](https://github.com/carbon-design-system/carbon-charts/blob/master/CONTRIBUTING.md)
before starting any work.
We recommend the use of
[](https://github.com/webpack/webpack-dev-server) for developing components.
**Start the server:**
\`\`\`bash
cd packages/core
yarn demo:server
\`\`\`
Open browser to \`http://localhost:9006\`
View available components [here](https://github.com/carbon-design-system/carbon-charts#component-status)
If you experience any issues while getting set up with Carbon Charts, please head
over to the [GitHub repo](https://github.com/carbon-design-system/carbon-charts)
for more guidelines and support.
Please [create an issue](https://github.com/carbon-design-system/carbon-charts/issues)
if your issue does not already exist.
`),
};