mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +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,100 @@
|
||||
/*
|
||||
* 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, getChartTransformPropsRegistry } from '@superset-ui/core';
|
||||
import AgGridTableChartPlugin from '../index';
|
||||
import transformProps from '../transformProps';
|
||||
import { basicFormData, basicData } from './data';
|
||||
import { withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
const VIZ_TYPE = 'ag-grid-table';
|
||||
|
||||
new AgGridTableChartPlugin().configure({ key: VIZ_TYPE }).register();
|
||||
|
||||
getChartTransformPropsRegistry().registerValue(VIZ_TYPE, transformProps);
|
||||
|
||||
export default {
|
||||
title: 'Chart Plugins/plugin-chart-ag-grid-table',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
includeSearch: true,
|
||||
showCellBars: true,
|
||||
alignPn: false,
|
||||
colorPn: true,
|
||||
},
|
||||
argTypes: {
|
||||
includeSearch: {
|
||||
control: 'boolean',
|
||||
description: 'Show search box',
|
||||
},
|
||||
showCellBars: {
|
||||
control: 'boolean',
|
||||
description: 'Show cell bars for numeric columns',
|
||||
},
|
||||
alignPn: {
|
||||
control: 'boolean',
|
||||
description: 'Align positive/negative values',
|
||||
},
|
||||
colorPn: {
|
||||
control: 'boolean',
|
||||
description: 'Color positive/negative values',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
includeSearch,
|
||||
showCellBars,
|
||||
alignPn,
|
||||
colorPn,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
includeSearch: boolean;
|
||||
showCellBars: boolean;
|
||||
alignPn: boolean;
|
||||
colorPn: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VIZ_TYPE}
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={{
|
||||
columnFormats: {},
|
||||
verboseMap: {},
|
||||
}}
|
||||
queriesData={[basicData]}
|
||||
formData={{
|
||||
...basicFormData,
|
||||
include_search: includeSearch,
|
||||
show_cell_bars: showCellBars,
|
||||
align_pn: alignPn,
|
||||
color_pn: colorPn,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Basic.parameters = {
|
||||
initialSize: {
|
||||
width: 680,
|
||||
height: 420,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 { GenericDataType } from '@apache-superset/core/api/core';
|
||||
import { ChartDataResponseResult, VizType } from '@superset-ui/core';
|
||||
import { TableChartFormData } from '../types';
|
||||
|
||||
export const basicFormData: TableChartFormData = {
|
||||
datasource: '1__table',
|
||||
viz_type: VizType.Table,
|
||||
align_pn: false,
|
||||
color_pn: true,
|
||||
include_search: true,
|
||||
groupby: ['name', 'category'],
|
||||
metrics: ['sum__num'],
|
||||
order_desc: true,
|
||||
page_length: 0,
|
||||
percent_metrics: null,
|
||||
show_cell_bars: true,
|
||||
table_timestamp_format: 'smart_date',
|
||||
};
|
||||
|
||||
export const basicData: Partial<ChartDataResponseResult> = {
|
||||
colnames: ['name', 'category', 'sum__num'],
|
||||
coltypes: [
|
||||
GenericDataType.String,
|
||||
GenericDataType.String,
|
||||
GenericDataType.Numeric,
|
||||
],
|
||||
data: [
|
||||
{ name: 'Michael', category: 'A', sum__num: 2467063 },
|
||||
{ name: 'Christopher', category: 'B', sum__num: 1725265 },
|
||||
{ name: 'David', category: 'A', sum__num: 1570516 },
|
||||
{ name: 'James', category: 'C', sum__num: 1506025 },
|
||||
{ name: 'John', category: 'B', sum__num: 1426074 },
|
||||
{ name: 'Matthew', category: 'A', sum__num: 1355803 },
|
||||
{ name: 'Robert', category: 'C', sum__num: 1314800 },
|
||||
{ name: 'Daniel', category: 'B', sum__num: 1159354 },
|
||||
{ name: 'Joseph', category: 'A', sum__num: 1114098 },
|
||||
{ name: 'William', category: 'C', sum__num: 1113701 },
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user