forked from carbon-design-system/carbon-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dataviz demo pages (carbon-design-system#2223)
* update dataviz demo pages * update chart types page links * final touches * add boxplot & wordcloud images * add lollipop to demos and move wordcloud into comparisons
- Loading branch information
1 parent
bc16d1a
commit fa02dff
Showing
63 changed files
with
371 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.mdx-icon { | ||
width: 32px; | ||
max-height: 32px; | ||
object-fit: contain; | ||
position: relative; | ||
display: inline-block; | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
|
||
import * as ChartComponents from '@carbon/charts-react'; | ||
|
||
import H2 from 'gatsby-theme-carbon/src/components/markdown/H2'; | ||
import P from 'gatsby-theme-carbon/src/components/markdown/P'; | ||
import CodeBar from '../ComponentDemo/Code/CodeBar.js'; | ||
|
||
import { | ||
CardGroup, | ||
MiniCard, | ||
} from 'gatsby-theme-carbon/src/components/MiniCard'; | ||
|
||
import STORYBOOK_LOGO from '../../images/storybook-icon.svg'; | ||
|
||
const generateHeadingID = (title) => | ||
title | ||
.split(' ') | ||
.map((t) => t.toLowerCase()) | ||
.join('-'); | ||
|
||
const ChartDemoGroup = ({ demoGroup, light }) => { | ||
let demo = demoGroup.demos.find((d) => d.mainDemo === true); | ||
if (!demo) { | ||
demo = demoGroup.demos[0]; | ||
} | ||
|
||
const DemoComponent = ChartComponents[demo.chartType.vanilla]; | ||
|
||
const numberOfRemainingDemos = | ||
demoGroup.demos.length > 2 ? demoGroup.demos.length - 1 : 0; | ||
|
||
return ( | ||
<div> | ||
{light !== true && <H2>{demoGroup.title}</H2>} | ||
|
||
{light !== true && demoGroup.description && ( | ||
<div className="bx--row"> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<P className="dataviz-copy">{demoGroup.description}</P> | ||
</div> | ||
</div> | ||
)} | ||
|
||
<> | ||
{light !== true && demo.description && ( | ||
<div className="bx--row"> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<P className="dataviz-copy">{demo.description}</P> | ||
</div> | ||
</div> | ||
)} | ||
|
||
<div className="bx--row" style={{ marginTop: "1.5rem"}}> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<div | ||
className="chart-demo-wrapper" | ||
id={generateHeadingID(demo.title)}> | ||
<div className="chart-demo"> | ||
<DemoComponent | ||
data={demo.data} | ||
options={demo.options} | ||
style={{ maxWidth: 400 }} | ||
/> | ||
</div> | ||
|
||
<CodeBar | ||
links={{ | ||
React: demo.codesandbox.react, | ||
Angular: `https://carbon-design-system.github.io/carbon-charts/angular/?path=/story/${demo.id}`, | ||
Vue: demo.codesandbox.vue, | ||
Vanilla: demo.codesandbox.vanilla, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{numberOfRemainingDemos > 0 && ( | ||
<MiniCard | ||
title={`${numberOfRemainingDemos} more demo${ | ||
numberOfRemainingDemos > 1 ? 's' : '' | ||
}`} | ||
href={`https://carbon-design-system.github.io/carbon-charts/?path=/story/${demoGroup.type.replace( | ||
'-chart', | ||
'' | ||
)}-charts-${demo.id}`}> | ||
<img src={STORYBOOK_LOGO} style={{ height: 20 }} /> | ||
</MiniCard> | ||
)} | ||
</> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChartDemoGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import { demoGroups as dG } from '@carbon/charts/demo/data'; | ||
import { storybookDemoGroups } from '@carbon/charts/demo/data'; | ||
|
||
// Merge all demoGroups with matching names | ||
const demoGroups = []; | ||
dG.forEach((demoGroup) => { | ||
const demoGroupTitle = demoGroup.title; | ||
const demoGroupExistingIndex = demoGroups.findIndex( | ||
(dg) => dg.title === demoGroupTitle | ||
); | ||
export const simpleChartDemoGroups = storybookDemoGroups.filter( | ||
(demoGroup) => demoGroup.type === 'simple-chart' | ||
); | ||
|
||
if (demoGroupExistingIndex === -1) { | ||
demoGroups.push(demoGroup); | ||
} else { | ||
const existingDemos = demoGroups[demoGroupExistingIndex].demos; | ||
demoGroups[demoGroupExistingIndex].demos = existingDemos.concat( | ||
demoGroup.demos | ||
); | ||
} | ||
}); | ||
export const complexChartDemoGroups = storybookDemoGroups.filter( | ||
(demoGroup) => demoGroup.type === 'complex-chart' | ||
); | ||
|
||
export default demoGroups; | ||
export const getDemoGroupByTitle = (title) => | ||
storybookDemoGroups.find( | ||
(demoGroup) => demoGroup.title.toLowerCase() === title.toLowerCase() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions
56
src/pages/data-visualization/chart-types/images/boxplot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
src/pages/data-visualization/chart-types/images/lollipop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.