Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): examples to open as sandbox (#820)
- Loading branch information
Showing
65 changed files
with
1,027 additions
and
382 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"src/**/*.{ts,tsx}": ["eslint", "prettier --write"], | ||
"stories/**/*.{ts,tsx}": ["eslint", "prettier --write"], | ||
"sandboxes/**/*.{ts,tsx}": ["eslint", "prettier --write"], | ||
"test/**/*.{ts,tsx}": ["eslint", "prettier --write"] | ||
} |
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,10 +1,14 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
stories: [ | ||
'../stories/*.tsx' | ||
], | ||
stories: ['../stories/*.tsx'], | ||
addons: [ | ||
'@storybook/addon-docs', | ||
'@storybook/addon-controls', | ||
'@storybook/addon-actions', | ||
], | ||
} | ||
webpackFinal(config) { | ||
config.resolve.alias['react-chartjs-2'] = path.resolve(__dirname, '../src'); | ||
return config; | ||
}, | ||
}; |
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,8 +1,8 @@ | ||
import { addons } from '@storybook/addons'; | ||
|
||
import { theme } from './theme' | ||
import { theme } from './theme'; | ||
|
||
addons.setConfig({ | ||
theme, | ||
panelPosition: 'right', | ||
}) | ||
}); |
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,5 @@ | ||
import { configureActions } from '@storybook/addon-actions' | ||
import { configureActions } from '@storybook/addon-actions'; | ||
|
||
configureActions({ | ||
depth: 5, | ||
}) | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
import faker from 'faker'; | ||
|
||
export const options = { | ||
plugins: { | ||
title: { | ||
display: true, | ||
text: 'Chart.js Bar Chart - Stacked', | ||
}, | ||
}, | ||
responsive: true, | ||
interaction: { | ||
mode: 'index' as const, | ||
intersect: false, | ||
}, | ||
scales: { | ||
x: { | ||
stacked: true, | ||
}, | ||
y: { | ||
stacked: true, | ||
}, | ||
}, | ||
}; | ||
|
||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; | ||
|
||
export const data = { | ||
labels, | ||
datasets: [ | ||
{ | ||
label: 'Dataset 1', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(255, 99, 132)', | ||
stack: 'Stack 0', | ||
}, | ||
{ | ||
label: 'Dataset 2', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(75, 192, 192)', | ||
stack: 'Stack 0', | ||
}, | ||
{ | ||
label: 'Dataset 3', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(53, 162, 235)', | ||
stack: 'Stack 1', | ||
}, | ||
], | ||
}; | ||
|
||
export function App() { | ||
return <Bar options={options} data={data} />; | ||
} |
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,7 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
import { App } from './App'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
render(<App />, rootElement); |
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,16 @@ | ||
{ | ||
"main": "index.tsx", | ||
"dependencies": { | ||
"chart.js": "^3.6.0", | ||
"faker": "5.5.3", | ||
"react": "17.0.2", | ||
"react-chartjs-2": "^3.3.0", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "17.0.20", | ||
"@types/react-dom": "17.0.9", | ||
"typescript": "4.4.2" | ||
} | ||
} |
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,46 @@ | ||
import React from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
import faker from 'faker'; | ||
|
||
export const options = { | ||
indexAxis: 'y' as const, | ||
elements: { | ||
bar: { | ||
borderWidth: 2, | ||
}, | ||
}, | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
position: 'right' as const, | ||
}, | ||
title: { | ||
display: true, | ||
text: 'Chart.js Horizontal Bar Chart', | ||
}, | ||
}, | ||
}; | ||
|
||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; | ||
|
||
export const data = { | ||
labels, | ||
datasets: [ | ||
{ | ||
label: 'Dataset 1', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
borderColor: 'rgb(255, 99, 132)', | ||
backgroundColor: 'rgba(255, 99, 132, 0.5)', | ||
}, | ||
{ | ||
label: 'Dataset 2', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
borderColor: 'rgb(53, 162, 235)', | ||
backgroundColor: 'rgba(53, 162, 235, 0.5)', | ||
}, | ||
], | ||
}; | ||
|
||
export function App() { | ||
return <Bar options={options} data={data} />; | ||
} |
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,7 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
import { App } from './App'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
render(<App />, rootElement); |
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,16 @@ | ||
{ | ||
"main": "index.tsx", | ||
"dependencies": { | ||
"chart.js": "^3.6.0", | ||
"faker": "5.5.3", | ||
"react": "17.0.2", | ||
"react-chartjs-2": "^3.3.0", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "17.0.20", | ||
"@types/react-dom": "17.0.9", | ||
"typescript": "4.4.2" | ||
} | ||
} |
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,48 @@ | ||
import React from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
import faker from 'faker'; | ||
|
||
export const options = { | ||
plugins: { | ||
title: { | ||
display: true, | ||
text: 'Chart.js Bar Chart - Stacked', | ||
}, | ||
}, | ||
responsive: true, | ||
scales: { | ||
x: { | ||
stacked: true, | ||
}, | ||
y: { | ||
stacked: true, | ||
}, | ||
}, | ||
}; | ||
|
||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; | ||
|
||
export const data = { | ||
labels, | ||
datasets: [ | ||
{ | ||
label: 'Dataset 1', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(255, 99, 132)', | ||
}, | ||
{ | ||
label: 'Dataset 2', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(75, 192, 192)', | ||
}, | ||
{ | ||
label: 'Dataset 3', | ||
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })), | ||
backgroundColor: 'rgb(53, 162, 235)', | ||
}, | ||
], | ||
}; | ||
|
||
export function App() { | ||
return <Bar options={options} data={data} />; | ||
} |
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,7 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
import { App } from './App'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
render(<App />, rootElement); |
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,16 @@ | ||
{ | ||
"main": "index.tsx", | ||
"dependencies": { | ||
"chart.js": "^3.6.0", | ||
"faker": "5.5.3", | ||
"react": "17.0.2", | ||
"react-chartjs-2": "^3.3.0", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "17.0.20", | ||
"@types/react-dom": "17.0.9", | ||
"typescript": "4.4.2" | ||
} | ||
} |
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,38 @@ | ||
import React from 'react'; | ||
import { Bar } from 'react-chartjs-2'; | ||
import faker from 'faker'; | ||
|
||
export const options = { | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
position: 'top' as const, | ||
}, | ||
title: { | ||
display: true, | ||
text: 'Chart.js Bar Chart', | ||
}, | ||
}, | ||
}; | ||
|
||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; | ||
|
||
export const data = { | ||
labels, | ||
datasets: [ | ||
{ | ||
label: 'Dataset 1', | ||
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })), | ||
backgroundColor: 'rgba(255, 99, 132, 0.5)', | ||
}, | ||
{ | ||
label: 'Dataset 2', | ||
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })), | ||
backgroundColor: 'rgba(53, 162, 235, 0.5)', | ||
}, | ||
], | ||
}; | ||
|
||
export function App() { | ||
return <Bar options={options} data={data} />; | ||
} |
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,7 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
import { App } from './App'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
render(<App />, rootElement); |
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,16 @@ | ||
{ | ||
"main": "index.tsx", | ||
"dependencies": { | ||
"chart.js": "^3.6.0", | ||
"faker": "5.5.3", | ||
"react": "17.0.2", | ||
"react-chartjs-2": "^3.3.0", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "17.0.20", | ||
"@types/react-dom": "17.0.9", | ||
"typescript": "4.4.2" | ||
} | ||
} |
Oops, something went wrong.