Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codesandbox examples for charting demos #987

Merged
merged 37 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
dd68a29
initial effort
theiliad Mar 5, 2020
6ec0736
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Mar 5, 2020
7c5c499
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 5, 2020
59dbe60
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 6, 2020
59806b6
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 9, 2020
5d0e2a7
add dynamic demos to basic charts
theiliad Apr 9, 2020
c4c8869
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Apr 9, 2020
0669dc5
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 5, 2020
a152988
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 5, 2020
f9eb9b1
update charting package version, optimize demo components
theiliad Jun 5, 2020
c10e8cf
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 5, 2020
18aa499
fix lint error
theiliad Jun 8, 2020
f513625
update @carbon/charts to 0.32.3
theiliad Jun 9, 2020
1defb65
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 9, 2020
31b1e59
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 9, 2020
076e799
Merge branch 'master' into codesandbox-dataviz
tw15egan Jun 9, 2020
ce03c2d
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 10, 2020
dab52f9
add image alt tags to dataviz chart types page
theiliad Jun 10, 2020
52a7a1e
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 11, 2020
e606862
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 11, 2020
483dde1
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 12, 2020
1ace04a
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 12, 2020
9bd44fb
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 12, 2020
1ed2c49
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 12, 2020
94b2702
update yarn.lock
theiliad Jun 12, 2020
5f3fb27
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 12, 2020
07990b3
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 15, 2020
82388ad
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 16, 2020
df93656
fix styling issues
theiliad Jun 16, 2020
d77fe25
styling fixes
theiliad Jun 22, 2020
a2c3aa8
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 22, 2020
15f2d99
undo overview-card tag height change
theiliad Jun 22, 2020
d34c8f7
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 22, 2020
2a31fac
move resources below anchor links for basic charts page
theiliad Jun 22, 2020
87f4d6b
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 22, 2020
1145a1e
final touch on CodeBar
theiliad Jun 22, 2020
4b8bd93
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"last 1 chrome version"
],
"dependencies": {
"@carbon/charts": "^0.28.1",
"@carbon/charts-react": "^0.28.1",
"@carbon/charts": "^0.30.10",
"@carbon/charts-react": "^0.30.10",
"@carbon/elements": "^10.9.2",
"@carbon/icons": "^10.9.1",
"@carbon/icons-react": "^10.9.1",
Expand Down
13 changes: 11 additions & 2 deletions src/components/ComponentDemo/ComponentDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import React, { useState, useContext } from 'react';
import prismTheme from 'gatsby-theme-carbon/src/components/Code/prismTheme';
import * as CarbonComponents from 'carbon-components-react';
import * as CarbonChartsComponents from '@carbon/charts-react';
import * as chartingDemoDataAndOptions from '@carbon/charts/demo/data';

import { LiveProvider, LiveEditor, LivePreview, LiveError } from 'react-live';
import { Row } from 'gatsby-theme-carbon';
import { TableOfContents20 } from '@carbon/icons-react';
Expand Down Expand Up @@ -55,7 +58,7 @@ const ComponentDemo = ({
// allow for write-in props
// Tests/cleanup context
// handle true/false better

console.log('theme', theme, theme.indexOf('g100') > -1);
theiliad marked this conversation as resolved.
Show resolved Hide resolved
return (
<ErrorBoundary>
<Row>
Expand All @@ -74,7 +77,12 @@ const ComponentDemo = ({
<LiveProvider
noInline={noInline}
theme={prismTheme}
scope={{ ...CarbonComponents, ...scope }}
scope={{
...CarbonComponents,
...CarbonChartsComponents,
...chartingDemoDataAndOptions,
...scope,
}}
code={code}>
<div className={cx(container, { [knoblessContainer]: !knobs })}>
<LivePreview className={cx(theme, previewContainer)} />
Expand All @@ -91,6 +99,7 @@ const ComponentDemo = ({
)}
<Code links={links} code={code} src={src}>
<LiveEditor
disabled
theiliad marked this conversation as resolved.
Show resolved Hide resolved
padding={16}
style={{ overflowX: 'auto', whiteSpace: 'pre' }}
onChange={updatedCode => setCode(updatedCode)}
Expand Down
7 changes: 4 additions & 3 deletions src/data/charts/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from './bar';
export * from './pie-donut';
export * from './line';
import * as de from '@carbon/charts/demo/data';

export * from '@carbon/charts/demo/data';

console.log('de', de);
theiliad marked this conversation as resolved.
Show resolved Hide resolved
export const addHeightToOptions = options => ({
...options,
height: '400px',
Expand Down
74 changes: 74 additions & 0 deletions src/pages/data-visualization/basic-charts/allDemos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';

import * as ChartComponents from '@carbon/charts-react';
import { demoGroups } from '@carbon/charts/demo/data';

import { Launch16 } from '@carbon/icons-react';

import WRITEUPS from "./writeups";

const generateHeadingID = title => title.split(" ")
.map(title => title.toLowerCase()).join("-");

export default () => (
<>
{demoGroups.map(demoGroup => {
return (
<>
<h2 id={generateHeadingID(demoGroup.title)}>{demoGroup.title}</h2>

{WRITEUPS[demoGroup.title] && <p>{WRITEUPS[demoGroup.title]}</p>}

{demoGroup.demos.map(demo => {
const DemoComponent = ChartComponents[demo.chartType.vanilla];
return (
<>
{WRITEUPS[demo.title] && <p>{WRITEUPS[demo.title]}</p>}
<div className="charting-demo with-margin-bottom">
<DemoComponent
data={demo.data}
options={demo.options}
style={{ maxWidth: 400 }}
/>

<div className="component-toolbar" style={{ marginTop: 0 }}>
<div className="component-toolbar__current">CodeSandbox:</div>
<div className="component-toolbar__links">
<a
href={demo.codesandbox.vanilla}
target="_blank"
rel="noopener noreferrer">
vanilla <Launch16 />
</a>

<a
href={demo.codesandbox.react}
target="_blank"
rel="noopener noreferrer">
React <Launch16 />
</a>

<a
href={`https://carbon-design-system.github.io/carbon-charts/angular/?path=/story/${demo.id}`}
target="_blank"
rel="noopener noreferrer">
Angular <Launch16 />
</a>

<a
href={demo.codesandbox.vue}
target="_blank"
rel="noopener noreferrer">
Vue <Launch16 />
</a>
</div>
</div>
</div>
</>
);
})}
</>
);
})}
</>
);
14 changes: 14 additions & 0 deletions src/pages/data-visualization/basic-charts/anchorLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

import { storybookDemoGroups } from "@carbon/charts/demo/data";

import { AnchorLinks, AnchorLink } from 'gatsby-theme-carbon';
export default () => (
<AnchorLinks>
{storybookDemoGroups.map(storybookDemoGroup => (
<AnchorLink>{storybookDemoGroup.title}</AnchorLink>
))}

<AnchorLink>Design-only</AnchorLink>
</AnchorLinks>
);
166 changes: 12 additions & 154 deletions src/pages/data-visualization/basic-charts/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Basic charts offer a way to visualize data sets in an intuitive, easy to underst

</PageDescription>

import { CodeSnippet } from 'carbon-components-react';
theiliad marked this conversation as resolved.
Show resolved Hide resolved

import '@carbon/charts/styles.css';

import {
Expand Down Expand Up @@ -66,124 +68,21 @@ import {
scatterData,
} from '../../../data/charts/index';

<AnchorLinks>

<AnchorLink>Bar chart</AnchorLink>
<AnchorLink>Line chart</AnchorLink>
<AnchorLink>Area chart</AnchorLink>
<AnchorLink>Polar charts</AnchorLink>
<AnchorLink>Scatter plots</AnchorLink>
<AnchorLink>Meter and gauge</AnchorLink>

</AnchorLinks>

## Bar chart

### Default

Bar charts use vertical or horizontal data markers to compare individual values. You can use them to compare discrete data or show trends over time.

<SimpleBarChart
data={simpleBarData}
options={addHeightToOptions(simpleBarOptions)}
/>

<SimpleBarChart
data={simpleBarTimeSeriesData}
options={addHeightToOptions(simpleBarTimeSeriesOptions)}
/>

### Grouped bar chart

A grouped bar chart, also known as a clustered bar graph, multi-set bar chart, or grouped column chart, is a type of bar graph that is used to compare values across multiple categories.

<GroupedBarChart
data={groupedBarData}
options={addHeightToOptions(groupedBarOptions)}
/>

### Stacked bar

Stacked bar charts are useful for comparing proportional contributions within a category. They plot the relative value that each data series contributes to the total.

<StackedBarChart
data={stackedBarData}
options={addHeightToOptions(stackedBarOptions)}
/>

<StackedBarChart
data={stackedBarTimeSeriesData}
options={addHeightToOptions(stackedBarTimeSeriesOptions)}
/>

### Horizontal bar

### Default

Bar charts use vertical or horizontal data markers to compare individual values. You can use them to compare discrete data or show trends over time.

<SimpleBarChart
data={simpleHorizontalBarData}
options={addHeightToOptions(simpleHorizontalBarOptions)}
/>

<SimpleBarChart
data={simpleHorizontalBarTimeSeriesData}
options={addHeightToOptions(simpleHorizontalBarTimeSeriesOptions)}
/>

### Grouped bar chart

A grouped bar chart, also known as a clustered bar graph, multi-set bar chart, or grouped column chart, is a type of bar graph that is used to compare values across multiple categories.

<GroupedBarChart
data={groupedHorizontalBarData}
options={addHeightToOptions(groupedHorizontalBarOptions)}
/>

### Stacked bar

Stacked bar charts are useful for comparing proportional contributions within a category. They plot the relative value that each data series contributes to the total.

<StackedBarChart
data={stackedHorizontalBarData}
options={addHeightToOptions(stackedHorizontalBarOptions)}
/>

<StackedBarChart
data={stackedHorizontalBarTimeSeriesData}
options={addHeightToOptions(stackedHorizontalBarTimeSeriesOptions)}
/>

## Line chart

### Default

Line charts plot data at regular intervals connected by lines. You can use line visualizations to show trends over time and compare several data sets.
import BasicChartsAnchorLinks from './anchorLinks';
import AllDemos from './allDemos';

<LineChart data={lineData} options={addHeightToOptions(lineOptions)} />
<BasicChartsAnchorLinks />
<AllDemos />

<LineChart
data={lineTimeSeriesData}
options={addHeightToOptions(lineTimeSeriesOptions)}
/>
## Design-only

### Stepped line chart

Stepped line charts plot data at regular intervals, forming a series of steps between data points. You can use line visualizations to show trends over time and compare several data sets.

<LineChart data={stepData} options={addHeightToOptions(stepOptions)} />

### Curved line chart
<InlineNotification>

<LineChart
data={lineTimeSeriesData}
options={addHeightToOptions(lineTimeSeriesOptions)}
/>
Note: These charts are currently a work-in-progress. To see our roadmap, request missing guidance, or contribute content, please go to the carbon-charts [GitHub repository](https://github.com/carbon-design-system/carbon-charts).

## Area chart
</InlineNotification>

### Default
### Area chart

Area charts are similar to line charts, but the areas below the lines are filled with colors or patterns. Stacked charts are useful for comparing proportional contributions within a category. They plot the relative value that each data series contributes to the total.

Expand All @@ -199,12 +98,6 @@ Area charts are similar to line charts, but the areas below the lines are filled

Stacked area charts are useful for comparing proportional contributions within a category. They plot the relative value that each data series contributes to the total.

<InlineNotification>

Note: This chart is currently a work-in-progress. To see our roadmap, request missing guidance, or contribute content, please go to the carbon-charts [GitHub repository](https://github.com/carbon-design-system/carbon-charts).

</InlineNotification>

<Row>
<Column colLg={8} colMd={6} colSm={4}>

Expand All @@ -213,42 +106,7 @@ Note: This chart is currently a work-in-progress. To see our roadmap, request mi
</Column>
</Row>

## Polar charts

### Pie

<PieChart data={pieData} options={addHeightToOptions(pieOptions)} />

### Donut

<DonutChart data={donutData} options={addHeightToOptions(donutOptions)} />

## Scatter plots

### Default

Scatter plot visualizations use data points to plot two measures anywhere along a scale, not only at regular tick marks. You can use scatter plots to explore correlations between different measures.

<ScatterChart data={scatterData} options={addHeightToOptions(scatterOptions)} />

<ScatterChart
data={scatterTimeSeriesData}
options={addHeightToOptions(scatterTimeSeriesOptions)}
/>

### Bubble chart

Bubble charts use data points and bubbles to plot measures anywhere along a scale. One measure is plotted along each axis. The size of the bubble represents the third measure. You can use bubble charts to represent financial data or any data where measured values are related.

<Row>
<Column colLg={8} colMd={6} colSm={4}>

![Horizontal bar chart](images/charts-basic-bubble.png)

</Column>
</Row>

## Meter and gauge
### Meter and gauge

<InlineNotification>

Expand Down
9 changes: 9 additions & 0 deletions src/pages/data-visualization/basic-charts/writeups.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/pages/data-visualization/data-visualization.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ div.chart-holder {
background: $carbon--white-0;
padding: rem(30px);
}

.charting-demo {
max-width: 700px;
}

.charting-demo.with-margin-bottom {
margin-bottom: rem(60px);
}
2 changes: 1 addition & 1 deletion src/pages/updates/migration-guide/design.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The transition from v9 to v10 is primarily visual. The IBM color palette was upd

## IBM Design Language

Carbon v10 delivers the [IBM Design Language](https://www.ibm.com/design/language/) to product teams. It represents a complete visual refresh of the system, delivering the ethos of IBM Design. Carbon v10 is a modern, open-source framework for building digital products and experiences, with tooling and guidance on color, layout, typography, iconography, motion, patterns, and content.
Carbon v10 delivers the [IBM Design Language](https://www.ibm.com/design/language/) to product teams. It represents a complete visual refresh of the system, delivering the ethos of IBM Design. Carbon v10 is a modern, open-source framework for building digital products and experiences, with tooling and guidance on color, layout, typography, iconography, motion, patterns, and content.

## Design kit

Expand Down
Loading