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.
fix: bar label for many bars and long labels (#21)
* fix: labels for many bars in bar chart * fix: nvd3 bar labels * docs: update example
- Loading branch information
Showing
4 changed files
with
53 additions
and
4 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
39 changes: 39 additions & 0 deletions
39
...set-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DistBar/ManyBarStories.jsx
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,39 @@ | ||
/* eslint-disable no-magic-numbers */ | ||
import React from 'react'; | ||
import { SuperChart } from '@superset-ui/chart'; | ||
// import data from './data'; | ||
|
||
const data = [{ key: 'sth', values: [] }]; | ||
const LONG_LABEL = | ||
'some extremely ridiculously extremely extremely extremely ridiculously extremely extremely ridiculously extremely extremely ridiculously extremely long category'; | ||
|
||
for (let i = 0; i < 50; i += 1) { | ||
data[0].values.push({ | ||
x: `${LONG_LABEL.substring(0, Math.round(Math.random() * LONG_LABEL.length))} ${i + 1}`, | ||
y: Math.round(Math.random() * 10000), | ||
}); | ||
} | ||
|
||
export default [ | ||
{ | ||
renderStory: () => ( | ||
<SuperChart | ||
chartType="dist-bar" | ||
chartProps={{ | ||
datasource: { verboseMap: {} }, | ||
formData: { | ||
showBarValue: false, | ||
showLegend: true, | ||
vizType: 'dist_bar', | ||
xTicksLayout: 'auto', | ||
}, | ||
height: 800, | ||
payload: { data }, | ||
width: 400, | ||
}} | ||
/> | ||
), | ||
storyName: 'Many bars', | ||
storyPath: 'legacy-|preset-chart-nvd3|DistBarChartPlugin', | ||
}, | ||
]; |
3 changes: 2 additions & 1 deletion
3
...ages/superset-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DistBar/index.js
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,9 @@ | ||
import { DistBarChartPlugin } from '../../../../../superset-ui-legacy-preset-chart-nvd3'; | ||
import Stories from './Stories'; | ||
import ManyBarStories from './ManyBarStories'; | ||
|
||
new DistBarChartPlugin().configure({ key: 'dist-bar' }).register(); | ||
|
||
export default { | ||
examples: [...Stories], | ||
examples: [...Stories, ...ManyBarStories], | ||
}; |