mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
chore(storybook): consolidate storybook and enhance plugin stories (#37771)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
SuperChart,
|
||||
VizType,
|
||||
getChartTransformPropsRegistry,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
EchartsWaterfallChartPlugin,
|
||||
WaterfallTransformProps,
|
||||
} from '@superset-ui/plugin-chart-echarts';
|
||||
import data from './data';
|
||||
import { withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
new EchartsWaterfallChartPlugin()
|
||||
.configure({ key: VizType.Waterfall })
|
||||
.register();
|
||||
|
||||
getChartTransformPropsRegistry().registerValue(
|
||||
VizType.Waterfall,
|
||||
WaterfallTransformProps,
|
||||
);
|
||||
|
||||
export default {
|
||||
title: 'Chart Plugins/plugin-chart-echarts/Waterfall',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
xTicksLayout: '45°',
|
||||
showLegend: true,
|
||||
showValue: true,
|
||||
richTooltip: true,
|
||||
yAxisFormat: 'SMART_NUMBER',
|
||||
},
|
||||
argTypes: {
|
||||
xTicksLayout: {
|
||||
control: 'select',
|
||||
options: ['auto', 'flat', '45°', '90°', 'staggered'],
|
||||
},
|
||||
showLegend: { control: 'boolean' },
|
||||
showValue: { control: 'boolean' },
|
||||
richTooltip: { control: 'boolean' },
|
||||
yAxisFormat: {
|
||||
control: 'select',
|
||||
options: ['SMART_NUMBER', '.2f', '.0%', '$,.2f', '.3s', ',d'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Waterfall = ({
|
||||
width,
|
||||
height,
|
||||
xTicksLayout,
|
||||
showLegend,
|
||||
showValue,
|
||||
richTooltip,
|
||||
yAxisFormat,
|
||||
}: {
|
||||
width: number;
|
||||
height: number;
|
||||
xTicksLayout: string;
|
||||
showLegend: boolean;
|
||||
showValue: boolean;
|
||||
richTooltip: boolean;
|
||||
yAxisFormat: string;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VizType.Waterfall}
|
||||
width={width}
|
||||
height={height}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
metric: `SUM(decomp_volume)`,
|
||||
columns: 'due_to_group',
|
||||
series: 'period',
|
||||
x_ticks_layout: xTicksLayout,
|
||||
show_legend: showLegend,
|
||||
show_value: showValue,
|
||||
rich_tooltip: richTooltip,
|
||||
y_axis_format: yAxisFormat,
|
||||
adhocFilters: [
|
||||
{
|
||||
clause: 'WHERE',
|
||||
comparator: '0',
|
||||
expressionType: 'SIMPLE',
|
||||
filterOptionName: 'filter_8ix98su8zu4_t4767ixmbp9',
|
||||
isExtra: false,
|
||||
isNew: false,
|
||||
operator: '!=',
|
||||
sqlExpression: null,
|
||||
subject: 'period',
|
||||
},
|
||||
],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default [
|
||||
{ due_to_group: 'Facebook', period: '2020', 'SUM(decomp_volume)': 1945565.5 },
|
||||
{
|
||||
due_to_group: 'Competitor TV Advertising',
|
||||
period: '2019',
|
||||
'SUM(decomp_volume)': 1213252,
|
||||
},
|
||||
{
|
||||
due_to_group: 'Online Advertising',
|
||||
period: '2018',
|
||||
'SUM(decomp_volume)': 999990,
|
||||
},
|
||||
{ due_to_group: 'COREBASE', period: '2017', 'SUM(decomp_volume)': 852094 },
|
||||
{ due_to_group: 'COREBASE', period: '2018', 'SUM(decomp_volume)': 736576 },
|
||||
{ due_to_group: 'DISPLAY', period: '2017', 'SUM(decomp_volume)': 621608 },
|
||||
{ due_to_group: 'DISPLAY', period: '2018', 'SUM(decomp_volume)': 388904 },
|
||||
{ due_to_group: 'Facebook', period: '2019', 'SUM(decomp_volume)': 94909 },
|
||||
{
|
||||
due_to_group: 'Online Advertising',
|
||||
period: '2017',
|
||||
'SUM(decomp_volume)': 81334,
|
||||
},
|
||||
{ due_to_group: 'Halo TV', period: '2018', 'SUM(decomp_volume)': 66828 },
|
||||
{ due_to_group: 'Halo TV', period: '2017', 'SUM(decomp_volume)': 46818 },
|
||||
{
|
||||
due_to_group: 'Competitor TV Advertising',
|
||||
period: '2017',
|
||||
'SUM(decomp_volume)': 25252,
|
||||
},
|
||||
{ due_to_group: 'Facebook', period: '2017', 'SUM(decomp_volume)': 23932 },
|
||||
{ due_to_group: 'DFSI', period: '2017', 'SUM(decomp_volume)': 21466 },
|
||||
{ due_to_group: 'Coupons', period: '2017', 'SUM(decomp_volume)': 11160 },
|
||||
{ due_to_group: 'Facebook', period: '2018', 'SUM(decomp_volume)': 9444 },
|
||||
{ due_to_group: 'DFSI', period: '2019', 'SUM(decomp_volume)': 8785 },
|
||||
{
|
||||
due_to_group: 'Competitive Coupons',
|
||||
period: '2017',
|
||||
'SUM(decomp_volume)': 8724,
|
||||
},
|
||||
{
|
||||
due_to_group: 'Competitive Coupons',
|
||||
period: '2019',
|
||||
'SUM(decomp_volume)': 8724,
|
||||
},
|
||||
{ due_to_group: 'Coupons', period: '2019', 'SUM(decomp_volume)': 2950 },
|
||||
{ due_to_group: 'BB Display', period: '2019', 'SUM(decomp_volume)': 1844 },
|
||||
{ due_to_group: 'BB Display', period: '2017', 'SUM(decomp_volume)': 1844 },
|
||||
{ due_to_group: 'Email', period: '2017', 'SUM(decomp_volume)': 810 },
|
||||
{ due_to_group: 'OTHER', period: '2017', 'SUM(decomp_volume)': 78 },
|
||||
{ due_to_group: 'Email', period: '2019', 'SUM(decomp_volume)': -987000 },
|
||||
{ due_to_group: 'Email', period: '2020', 'SUM(decomp_volume)': -998988 },
|
||||
{
|
||||
due_to_group: 'Online Advertising',
|
||||
period: '2020',
|
||||
'SUM(decomp_volume)': -1500000.7,
|
||||
},
|
||||
{
|
||||
due_to_group: 'Online Advertising',
|
||||
period: '2019',
|
||||
'SUM(decomp_volume)': -1671652,
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user