This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(preset-chart-xy): migrate from plugins repo (#377)
* chore: move chart-xy and word-cloud * fix: babel settings * fix: remove file * docs: update storybook code * docs: word cloud storybook working * chore: move files back * fix: ts issues * fix: import path * fix: all storybook thingy * fix: add query storybook back * fix: address comments * fix: sorting
- Loading branch information
Showing
114 changed files
with
1,086 additions
and
1,097 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// eslint-disable-next-line no-undef, import/no-extraneous-dependencies | ||
const { getConfig } = require('@airbnb/config-babel'); | ||
|
||
const config = getConfig({ | ||
library: true, | ||
react: true, | ||
next: true, | ||
node: process.env.NODE_ENV === 'test', | ||
typescript: true, | ||
env: { | ||
targets: false, | ||
}, | ||
}); | ||
|
||
if (process.env.NODE_ENV !== 'test') { | ||
config.presets[0][1].modules = false; | ||
} | ||
|
||
// Override to allow transpile es modules inside vega-lite | ||
config.ignore = config.ignore.filter(item => item !== 'node_modules/'); | ||
config.ignore.push('node_modules/(?!(vega-lite|lodash-es))'); | ||
|
||
// eslint-disable-next-line no-undef | ||
module.exports = 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
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
74 changes: 74 additions & 0 deletions
74
packages/superset-ui-demo/storybook/shared/components/createQueryStory.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,74 @@ | ||
import React from 'react'; | ||
import { text, select } from '@storybook/addon-knobs'; | ||
import { SuperChart, ChartDataProvider } from '@superset-ui/chart'; | ||
import { SupersetClient } from '@superset-ui/connection'; | ||
import Expandable from './Expandable'; | ||
import VerifyCORS, { renderError } from './VerifyCORS'; | ||
|
||
export default function createQueryStory({ | ||
choices, | ||
}: { | ||
choices: { | ||
[key: string]: { | ||
chartType: string; | ||
formData: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
}; | ||
}) { | ||
const keys = Object.keys(choices); | ||
|
||
return () => { | ||
const host = text('Set Superset App host for CORS request', 'localhost:8088'); | ||
const mode = select('Choose mode:', keys, keys[0]); | ||
const { formData: presetFormData, chartType } = choices[mode]; | ||
const width = text('Vis width', '400'); | ||
const height = text('Vis height', '400'); | ||
const formData = text('Override formData', JSON.stringify(presetFormData, null, 2)); | ||
|
||
return ( | ||
<div style={{ margin: 16 }}> | ||
<VerifyCORS host={host}> | ||
{() => ( | ||
<ChartDataProvider | ||
client={SupersetClient} | ||
formData={JSON.parse(formData.replace(/"/g, '"'))} | ||
> | ||
{({ loading, payload, error }) => { | ||
if (loading) return <div>Loading!</div>; | ||
|
||
if (error) return renderError(error); | ||
|
||
if (payload) | ||
return ( | ||
<> | ||
<SuperChart | ||
chartType={chartType} | ||
width={width} | ||
height={height} | ||
formData={payload.formData} | ||
// @TODO fix typing | ||
// all vis's now expect objects but api/v1/ returns an array | ||
queryData={ | ||
Array.isArray(payload.queryData) | ||
? payload.queryData[0] | ||
: payload.queryData | ||
} | ||
/> | ||
<br /> | ||
<Expandable expandableWhat="payload"> | ||
<pre style={{ fontSize: 11 }}>{JSON.stringify(payload, null, 2)}</pre> | ||
</Expandable> | ||
</> | ||
); | ||
|
||
return null; | ||
}} | ||
</ChartDataProvider> | ||
)} | ||
</VerifyCORS> | ||
</div> | ||
); | ||
}; | ||
} |
135 changes: 135 additions & 0 deletions
135
packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-word-cloud/Stories.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,135 @@ | ||
import React from 'react'; | ||
import { SuperChart } from '@superset-ui/chart'; | ||
import { select, withKnobs } from '@storybook/addon-knobs'; | ||
import WordCloudChartPlugin from '@superset-ui/plugin-chart-word-cloud'; | ||
import LegacyWordCloudChartPlugin from '@superset-ui/plugin-chart-word-cloud/esm/legacy'; | ||
import data from './data'; | ||
|
||
new WordCloudChartPlugin().configure({ key: 'word-cloud2' }).register(); | ||
new LegacyWordCloudChartPlugin().configure({ key: 'legacy-word-cloud2' }).register(); | ||
|
||
export default { | ||
title: 'Chart Plugins|plugin-chart-word-cloud', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
export const basic = () => ( | ||
<SuperChart | ||
chartType="word-cloud2" | ||
width={400} | ||
height={400} | ||
queryData={{ data }} | ||
formData={{ | ||
encoding: { | ||
color: { | ||
value: '#0097e6', | ||
}, | ||
fontSize: { | ||
field: 'sum__num', | ||
scale: { | ||
range: [0, 70], | ||
zero: true, | ||
}, | ||
type: 'quantitative', | ||
}, | ||
text: { | ||
field: 'name', | ||
}, | ||
}, | ||
metric: 'sum__num', | ||
rotation: select('Rotation', ['square', 'flat', 'random'], 'flat'), | ||
series: 'name', | ||
}} | ||
/> | ||
); | ||
|
||
export const encodesColorByWordLength = () => ( | ||
<SuperChart | ||
chartType="word-cloud2" | ||
width={400} | ||
height={400} | ||
queryData={{ data }} | ||
formData={{ | ||
encoding: { | ||
color: { | ||
field: 'name.length', | ||
scale: { | ||
range: ['#fbc531', '#c23616'], | ||
type: 'linear', | ||
zero: false, | ||
}, | ||
type: 'quantitative', | ||
}, | ||
fontSize: { | ||
field: 'sum__num', | ||
scale: { | ||
range: [0, 70], | ||
zero: true, | ||
}, | ||
type: 'quantitative', | ||
}, | ||
text: { | ||
field: 'name', | ||
}, | ||
}, | ||
metric: 'sum__num', | ||
rotation: select('Rotation', ['square', 'flat', 'random'], 'flat'), | ||
series: 'name', | ||
}} | ||
/> | ||
); | ||
|
||
export const encodesFontByFirstLetter = () => ( | ||
<SuperChart | ||
chartType="word-cloud2" | ||
width={400} | ||
height={400} | ||
queryData={{ data }} | ||
formData={{ | ||
encoding: { | ||
color: { | ||
value: '#8c7ae6', | ||
}, | ||
fontFamily: { | ||
field: 'name[0]', | ||
scale: { | ||
range: ['Helvetica', 'Monaco'], | ||
type: 'ordinal', | ||
}, | ||
type: 'nominal', | ||
}, | ||
fontSize: { | ||
field: 'sum__num', | ||
scale: { | ||
range: [0, 70], | ||
zero: true, | ||
}, | ||
type: 'quantitative', | ||
}, | ||
text: { | ||
field: 'name', | ||
}, | ||
}, | ||
metric: 'sum__num', | ||
rotation: select('Rotation', ['square', 'flat', 'random'], 'flat'), | ||
series: 'name', | ||
}} | ||
/> | ||
); | ||
|
||
export const legacyShim = () => ( | ||
<SuperChart | ||
chartType="legacy-word-cloud2" | ||
width={400} | ||
height={400} | ||
queryData={{ data }} | ||
formData={{ | ||
colorScheme: 'd3Category10', | ||
metric: 'sum__num', | ||
rotation: select('Rotation', ['square', 'flat', 'random'], 'flat'), | ||
series: 'name', | ||
sizeFrom: '10', | ||
sizeTo: '70', | ||
}} | ||
/> | ||
); |
File renamed without changes.
13 changes: 5 additions & 8 deletions
13
.../stories/preset-chart-xy/BoxPlot/index.ts → ...ugins/preset-chart-xy/BoxPlot/Stories.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 |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { | ||
BoxPlotChartPlugin, | ||
LegacyBoxPlotChartPlugin, | ||
} from '../../../../../superset-ui-preset-chart-xy'; | ||
import Stories from './stories/Basic'; | ||
import LegacyStories from './stories/Legacy'; | ||
import { BoxPlotChartPlugin, LegacyBoxPlotChartPlugin } from '@superset-ui/preset-chart-xy'; | ||
import { BOX_PLOT_PLUGIN_LEGACY_TYPE, BOX_PLOT_PLUGIN_TYPE } from './constants'; | ||
|
||
new LegacyBoxPlotChartPlugin().configure({ key: BOX_PLOT_PLUGIN_LEGACY_TYPE }).register(); | ||
new BoxPlotChartPlugin().configure({ key: BOX_PLOT_PLUGIN_TYPE }).register(); | ||
|
||
export default { | ||
examples: [...Stories, ...LegacyStories], | ||
title: 'Chart Plugins|preset-chart-xy/BoxPlot', | ||
}; | ||
|
||
export { basic, horizontal } from './stories/Basic'; | ||
export { legacy } from './stories/Legacy'; |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
fb5370e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: