2018-02-06 02:36:22 +00:00
|
|
|
import {
|
|
|
|
nStoriesOfWithDefault,
|
|
|
|
action,
|
|
|
|
boolean,
|
|
|
|
text,
|
|
|
|
color,
|
|
|
|
array
|
2018-02-06 03:06:45 +00:00
|
|
|
} from './storybase.js'
|
2018-02-06 02:36:22 +00:00
|
|
|
|
2018-02-06 03:06:45 +00:00
|
|
|
import LineChart from '~/components/LineChart'
|
2018-02-06 02:36:22 +00:00
|
|
|
|
|
|
|
nStoriesOfWithDefault({ LineChart })
|
2018-02-06 03:06:45 +00:00
|
|
|
.add('with some data', () => ({
|
2018-02-06 02:36:22 +00:00
|
|
|
components: { LineChart },
|
|
|
|
template: `
|
|
|
|
<div>
|
|
|
|
<line-chart :data="{
|
|
|
|
labels: [1,2,3],
|
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: 'Sample',
|
|
|
|
backgroundColor: 'green',
|
|
|
|
data: ['1','2','3']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}" :options="{ maintainAspectRatio: false, responsive:true}"/>
|
|
|
|
</div>`
|
|
|
|
}))
|
2018-02-06 03:06:45 +00:00
|
|
|
.add('with knobs demo', () => {
|
|
|
|
const maintainAspectRatio = boolean('Aspect Ratio', false)
|
|
|
|
const responsive = boolean('Responsive', true)
|
|
|
|
const title = text('Title', 'Sample chart')
|
|
|
|
const myColor = color('Background Color', 'darkred')
|
2018-02-06 02:36:22 +00:00
|
|
|
|
2018-02-06 03:06:45 +00:00
|
|
|
const defaultValue = array('Values', [1, 2, 3, 6, 3, 8])
|
|
|
|
const defaultLabel = array('Labels', [
|
2018-02-06 02:36:22 +00:00
|
|
|
"'a'",
|
|
|
|
"'b'",
|
|
|
|
"'c'",
|
|
|
|
"'d'",
|
|
|
|
"'e'",
|
|
|
|
"'f'"
|
|
|
|
])
|
|
|
|
|
|
|
|
return {
|
|
|
|
components: { LineChart },
|
2018-02-06 03:06:45 +00:00
|
|
|
methods: { onResize: action('resized') },
|
2018-02-06 02:36:22 +00:00
|
|
|
template: `
|
|
|
|
<div style="position: relative; height:40vh; width:80vw">
|
|
|
|
<line-chart :data="{
|
|
|
|
labels: [${defaultLabel}],
|
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: '${title}',
|
|
|
|
backgroundColor: '${myColor}',
|
|
|
|
data: [${defaultValue}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}" :options="{ maintainAspectRatio: ${maintainAspectRatio}, responsive:${responsive}, onResize }"/>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
})
|
2018-02-06 03:06:45 +00:00
|
|
|
.addVT('with Vuetify', () => {
|
2018-02-06 02:36:22 +00:00
|
|
|
const data = { "'a'": 1, "'b'": 2, "'c'": 3 }
|
|
|
|
return `
|
|
|
|
<line-chart :data="{
|
|
|
|
labels: [${Object.keys(data)}],
|
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: 'list 1',
|
|
|
|
backgroundColor: '#41b883',
|
|
|
|
data: [${Object.values(data)}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}" :options="{ maintainAspectRatio: false, responsive:true}"/>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
.addVT(
|
2018-02-06 03:06:45 +00:00
|
|
|
'with Vuetify2',
|
|
|
|
`<line-chart :data="{
|
2018-02-06 02:36:22 +00:00
|
|
|
labels: [1,2,3],
|
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: 'list 2',
|
|
|
|
backgroundColor: '#41b883',
|
|
|
|
data: ['1','2','3']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}" :options="{ maintainAspectRatio: false, responsive:true}"/>
|
|
|
|
`
|
|
|
|
)
|