mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-25 06:49:15 +01:00
190 lines
4.4 KiB
JavaScript
Vendored
190 lines
4.4 KiB
JavaScript
Vendored
import React from 'react';
|
|
import {Bar} from 'react-chartjs-2';
|
|
import { storiesOf, action, linkTo } from '@kadira/storybook';
|
|
|
|
const options = {
|
|
responsive: true,
|
|
tooltips: {
|
|
mode: 'label'
|
|
},
|
|
elements: {
|
|
line: {
|
|
fill: false
|
|
}
|
|
},
|
|
scales: {
|
|
xAxes: [
|
|
{
|
|
display: true,
|
|
gridLines: {
|
|
display: false
|
|
},
|
|
labels: {
|
|
show: true
|
|
}
|
|
}
|
|
],
|
|
yAxes: [
|
|
{
|
|
type: 'linear',
|
|
display: true,
|
|
position: 'left',
|
|
id: 'y-axis-1',
|
|
gridLines: {
|
|
display: false
|
|
},
|
|
labels: {
|
|
show: true
|
|
}
|
|
},
|
|
{
|
|
type: 'linear',
|
|
display: true,
|
|
position: 'right',
|
|
id: 'y-axis-2',
|
|
gridLines: {
|
|
display: false
|
|
},
|
|
labels: {
|
|
show: true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
};
|
|
|
|
storiesOf('Mix Line+Bar Example', module)
|
|
.add('Line & Bar Stacked', () => {
|
|
const data = {
|
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
datasets: [{
|
|
label: 'Sales',
|
|
type:'line',
|
|
data: [51, 65, 40, 49, 60, 37, 40],
|
|
fill: false,
|
|
borderColor: '#EC932F',
|
|
backgroundColor: '#EC932F',
|
|
pointBorderColor: '#EC932F',
|
|
pointBackgroundColor: '#EC932F',
|
|
pointHoverBackgroundColor: '#EC932F',
|
|
pointHoverBorderColor: '#EC932F',
|
|
yAxisID: 'y-axis-2'
|
|
},{
|
|
type: 'bar',
|
|
label: 'Visitor',
|
|
data: [200, 185, 590, 621, 250, 400, 95],
|
|
fill: false,
|
|
backgroundColor: '#71B37C',
|
|
borderColor: '#71B37C',
|
|
hoverBackgroundColor: '#71B37C',
|
|
hoverBorderColor: '#71B37C',
|
|
yAxisID: 'y-axis-1'
|
|
}]
|
|
};
|
|
return <Bar data={data} options={options} />;
|
|
})
|
|
.add('Line & Line Stacked', () => {
|
|
const data = {
|
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
datasets: [{
|
|
label: 'Sales',
|
|
type:'line',
|
|
data: [51, 65, 40, 49, 60, 37, 40],
|
|
fill: false,
|
|
borderColor: '#EC932F',
|
|
backgroundColor: '#EC932F',
|
|
pointBorderColor: '#EC932F',
|
|
pointBackgroundColor: '#EC932F',
|
|
pointHoverBackgroundColor: '#EC932F',
|
|
pointHoverBorderColor: '#EC932F',
|
|
yAxisID: 'y-axis-2'
|
|
},{
|
|
type: 'line',
|
|
label: 'Visitor',
|
|
data: [200, 185, 590, 621, 250, 400, 95],
|
|
fill: false,
|
|
backgroundColor: '#71B37C',
|
|
borderColor: '#71B37C',
|
|
hoverBackgroundColor: '#71B37C',
|
|
hoverBorderColor: '#71B37C',
|
|
yAxisID: 'y-axis-1'
|
|
}]
|
|
};
|
|
return <Bar data={data} options={options} />;
|
|
})
|
|
.add('Line & Line Past vs. Future', () => {
|
|
const data = {
|
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
|
datasets: [{
|
|
label: 'Past',
|
|
type:'line',
|
|
data: [51, 65, 40, 49, , , ],
|
|
fill: false,
|
|
borderColor: '#EC932F',
|
|
backgroundColor: '#EC932F',
|
|
pointBorderColor: '#EC932F',
|
|
pointBackgroundColor: '#EC932F',
|
|
pointHoverBackgroundColor: '#EC932F',
|
|
pointHoverBorderColor: '#EC932F',
|
|
yAxisID: 'y-axis-2'
|
|
},{
|
|
type: 'line',
|
|
label: 'Future',
|
|
data: [, , , 49, 250, 400, 95],
|
|
fill: false,
|
|
backgroundColor: '#71B37C',
|
|
borderColor: '#71B37C',
|
|
hoverBackgroundColor: '#71B37C',
|
|
hoverBorderColor: '#71B37C',
|
|
yAxisID: 'y-axis-1'
|
|
}]
|
|
};
|
|
|
|
const optionsYaxes = {
|
|
type: 'linear',
|
|
display: true,
|
|
position: 'left',
|
|
id: 'y-axis-1',
|
|
gridLines: {
|
|
display: false
|
|
},
|
|
ticks: {
|
|
min: 0,
|
|
max: 400,
|
|
stepSize: 50,
|
|
},
|
|
labels: {
|
|
show: true
|
|
}
|
|
};
|
|
const optionsCustom = {
|
|
responsive: true,
|
|
tooltips: {
|
|
mode: 'label'
|
|
},
|
|
elements: {
|
|
line: {
|
|
fill: false
|
|
}
|
|
},
|
|
scales: {
|
|
xAxes: [
|
|
{
|
|
display: true,
|
|
gridLines: {
|
|
display: false
|
|
},
|
|
labels: {
|
|
show: true
|
|
}
|
|
}
|
|
],
|
|
yAxes: [
|
|
Object.assign({}, optionsYaxes, { id: 'y-axis-1' }),
|
|
Object.assign({}, optionsYaxes, { id: 'y-axis-2', display: false }),
|
|
]
|
|
}
|
|
};
|
|
return <Bar data={data} options={optionsCustom} />;
|
|
});
|