Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
feat(preset-chart-nvd3): migration from plugins repo (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored Apr 28, 2020
1 parent 672e02d commit dbd84f2
Show file tree
Hide file tree
Showing 125 changed files with 3,627 additions and 435 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AreaChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';

new AreaChartPlugin().configure({ key: 'area' }).register();

export default {
title: 'Legacy Chart Plugins|legacy-preset-chart-nvd3/Area',
};

export { stacked } from './stories/stacked';
export { stackedWithYAxisBounds, stackedWithYAxisBoundsMinOnly } from './stories/stackedWithBounds';
export { expanded } from './stories/expanded';
export { controlsShown } from './stories/controlsShown';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const controlsShown = () => (
<SuperChart
chartType="area"
datasource={dummyDatasource}
width={400}
height={400}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorCcheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBrush: 'auto',
showControls: true,
showLegend: true,
stackedStyle: 'stack',
vizType: 'area',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const expanded = () => (
<SuperChart
chartType="area"
datasource={dummyDatasource}
width={400}
height={400}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorCcheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'expand',
vizType: 'area',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const stacked = () => (
<SuperChart
id="stacked-area-chart"
chartType="area"
datasource={dummyDatasource}
width={400}
height={400}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorScheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'area',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const stackedWithYAxisBounds = () => (
<SuperChart
chartType="area"
datasource={dummyDatasource}
width={400}
height={400}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorCcheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'area',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [0, 3000000000],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);

stackedWithYAxisBounds.story = {
name: 'Stacked with yAxisBounds',
};

export const stackedWithYAxisBoundsMinOnly = () => (
<SuperChart
chartType="area"
datasource={dummyDatasource}
width={400}
height={400}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorCcheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBrush: 'auto',
showControls: true,
showLegend: true,
stackedStyle: 'stack',
vizType: 'area',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [1000000000, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);

stackedWithYAxisBoundsMinOnly.story = {
name: 'Stacked with yAxisBounds min only',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BarChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';

new BarChartPlugin().configure({ key: 'bar' }).register();

export default {
title: 'Legacy Chart Plugins|legacy-preset-chart-nvd3/Bar',
};

export { basic } from './stories/basic';
export { barWithValues } from './stories/barWithValues';
export { barWithPositiveAndNegativeValues } from './stories/barWithPositiveAndNegativeValues';
export { stackedBarWithValues } from './stories/stackedBarWithValues';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const barWithPositiveAndNegativeValues = () => (
<SuperChart
chartType="bar"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{
data: data.map((group, i) => ({
...group,
values: group.values.map(pair => ({ ...pair, y: (i % 2 === 0 ? 1 : -1) * pair.y })),
})),
}}
formData={{
bottomMargin: 'auto',
colorScheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBarValue: true,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'bar',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const barWithValues = () => (
<SuperChart
chartType="bar"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorScheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBarValue: false,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'bar',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const basic = () => (
<SuperChart
chartType="bar"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{ data }}
formData={{
bottomMargin: 'auto',
colorScheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBarValue: false,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'bar',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const stackedBarWithValues = () => (
<SuperChart
chartType="bar"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{ data }}
formData={{
barStacked: true,
bottomMargin: 'auto',
colorScheme: 'd3Category10',
contribution: false,
groupby: ['region'],
lineInterpolation: 'linear',
metrics: ['sum__SP_POP_TOTL'],
richTooltip: true,
showBarValue: true,
showBrush: 'auto',
showControls: false,
showLegend: true,
stackedStyle: 'stack',
vizType: 'bar',
xAxisFormat: '%Y',
xAxisLabel: '',
xAxisShowminmax: false,
xTicksLayout: 'auto',
yAxisBounds: [null, null],
yAxisFormat: '.3s',
yLogScale: false,
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BoxPlotChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';

new BoxPlotChartPlugin().configure({ key: 'box-plot' }).register();

export default {
title: 'Legacy Chart Plugins|legacy-preset-chart-nvd3/BoxPlot',
};

export { basic } from './stories/basic';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import dummyDatasource from '../../../../../shared/dummyDatasource';
import data from '../data';

export const basic = () => (
<SuperChart
chartType="box-plot"
width={400}
height={400}
datasource={dummyDatasource}
queryData={{ data }}
formData={{
colorScheme: 'd3Category10',
vizType: 'box_plot',
whiskerOptions: 'Min/max (no outliers)',
}}
/>
);
Loading

1 comment on commit dbd84f2

@vercel
Copy link

@vercel vercel bot commented on dbd84f2 Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.