This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement labelFlush behavior for continuous axes (#117)
* feat: add labelFlush to definition * feat: implement flushing
- Loading branch information
Showing
7 changed files
with
249 additions
and
37 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
136 changes: 136 additions & 0 deletions
136
packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/Line/stories/flush.tsx
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,136 @@ | ||
/* eslint-disable no-magic-numbers, sort-keys */ | ||
import * as React from 'react'; | ||
import { SuperChart, ChartProps } from '@superset-ui/chart'; | ||
import { radios } from '@storybook/addon-knobs'; | ||
import rawData from '../data/data'; | ||
import { LINE_PLUGIN_TYPE } from '../constants'; | ||
|
||
const MIN_TIME = new Date(Date.UTC(1980, 0, 1)).getTime(); | ||
const MAX_TIME = new Date(Date.UTC(2000, 1, 1)).getTime(); | ||
const data = rawData.filter(({ x }) => x >= MIN_TIME && x <= MAX_TIME); | ||
|
||
export default [ | ||
{ | ||
renderStory: () => [ | ||
<SuperChart | ||
key="line1" | ||
chartType={LINE_PLUGIN_TYPE} | ||
chartProps={ | ||
new ChartProps({ | ||
datasource: { verboseMap: {} }, | ||
formData: { | ||
encoding: { | ||
x: { | ||
field: 'x', | ||
type: 'temporal', | ||
format: '%Y', | ||
scale: { | ||
type: 'utc', | ||
}, | ||
axis: { | ||
tickCount: 6, | ||
orient: radios('x.axis.orient', { top: 'top', bottom: 'bottom' }, 'bottom'), | ||
title: radios( | ||
'x.axis.title', | ||
{ enable: 'Time', disable: '', '': undefined }, | ||
'Time', | ||
), | ||
}, | ||
}, | ||
y: { | ||
field: 'y', | ||
type: 'quantitative', | ||
scale: { | ||
type: 'linear', | ||
}, | ||
axis: { | ||
tickCount: 3, | ||
orient: radios( | ||
'y.axis.orient', | ||
{ left: 'left', right: 'right', '': undefined }, | ||
'left', | ||
), | ||
title: radios( | ||
'y.axis.title', | ||
{ enable: 'Score', disable: '', '': undefined }, | ||
'Score', | ||
), | ||
}, | ||
}, | ||
stroke: { | ||
field: 'name', | ||
type: 'nominal', | ||
legend: true, | ||
}, | ||
}, | ||
}, | ||
height: 200, | ||
payload: { data }, | ||
width: 400, | ||
}) | ||
} | ||
/>, | ||
<SuperChart | ||
key="line1" | ||
chartType={LINE_PLUGIN_TYPE} | ||
chartProps={ | ||
new ChartProps({ | ||
datasource: { verboseMap: {} }, | ||
formData: { | ||
encoding: { | ||
x: { | ||
field: 'x', | ||
type: 'temporal', | ||
format: '%Y', | ||
scale: { | ||
type: 'utc', | ||
}, | ||
axis: { | ||
labelFlush: 5, | ||
tickCount: 6, | ||
orient: radios('x.axis.orient', { top: 'top', bottom: 'bottom' }, 'bottom'), | ||
title: radios( | ||
'x.axis.title', | ||
{ enable: 'Time', disable: '', '': undefined }, | ||
'Time', | ||
), | ||
}, | ||
}, | ||
y: { | ||
field: 'y', | ||
type: 'quantitative', | ||
scale: { | ||
type: 'linear', | ||
}, | ||
axis: { | ||
tickCount: 3, | ||
orient: radios( | ||
'y.axis.orient', | ||
{ left: 'left', right: 'right', '': undefined }, | ||
'left', | ||
), | ||
title: radios( | ||
'y.axis.title', | ||
{ enable: 'Score', disable: '', '': undefined }, | ||
'Score', | ||
), | ||
}, | ||
}, | ||
stroke: { | ||
field: 'name', | ||
type: 'nominal', | ||
legend: true, | ||
}, | ||
}, | ||
}, | ||
height: 200, | ||
payload: { data }, | ||
width: 400, | ||
}) | ||
} | ||
/>, | ||
], | ||
storyName: 'with labelFlush', | ||
storyPath: 'preset-chart-xy|LineChartPlugin', | ||
}, | ||
]; |
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
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
Oops, something went wrong.