mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +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,101 @@
|
||||
/*
|
||||
* 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 } from '@superset-ui/core';
|
||||
import PartitionChartPlugin from '@superset-ui/legacy-plugin-chart-partition';
|
||||
import data from './data';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
new PartitionChartPlugin().configure({ key: VizType.Partition }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-plugin-chart-partition',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
logScale: false,
|
||||
equalDateSize: true,
|
||||
richTooltip: true,
|
||||
partitionLimit: 5,
|
||||
partitionThreshold: 0.05,
|
||||
},
|
||||
argTypes: {
|
||||
colorScheme: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'supersetColors',
|
||||
'd3Category10',
|
||||
'bnbColors',
|
||||
'googleCategory20c',
|
||||
],
|
||||
},
|
||||
logScale: { control: 'boolean' },
|
||||
equalDateSize: { control: 'boolean' },
|
||||
richTooltip: { control: 'boolean' },
|
||||
partitionLimit: {
|
||||
control: { type: 'range', min: 1, max: 20, step: 1 },
|
||||
description: 'Maximum number of partitions to show',
|
||||
},
|
||||
partitionThreshold: {
|
||||
control: { type: 'range', min: 0, max: 0.5, step: 0.01 },
|
||||
description: 'Minimum threshold for partition size',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
colorScheme,
|
||||
logScale,
|
||||
equalDateSize,
|
||||
richTooltip,
|
||||
partitionLimit,
|
||||
partitionThreshold,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
colorScheme: string;
|
||||
logScale: boolean;
|
||||
equalDateSize: boolean;
|
||||
richTooltip: boolean;
|
||||
partitionLimit: number;
|
||||
partitionThreshold: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VizType.Partition}
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
color_scheme: colorScheme,
|
||||
date_time_format: '%Y-%m-%d',
|
||||
equal_date_size: equalDateSize,
|
||||
groupby: ['region', 'country_code'],
|
||||
log_scale: logScale,
|
||||
metrics: ['sum__SP_POP_TOTL'],
|
||||
number_format: '.3s',
|
||||
partition_limit: String(partitionLimit),
|
||||
partition_threshold: String(partitionThreshold),
|
||||
rich_tooltip: richTooltip,
|
||||
time_series_option: 'not-time',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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 [
|
||||
{
|
||||
name: 'World',
|
||||
val: 165709793794.0,
|
||||
children: [
|
||||
{
|
||||
name: 'East Asia & Pacific',
|
||||
val: 74157936990.0,
|
||||
children: [
|
||||
{
|
||||
name: 'CHN',
|
||||
val: 58345455000.0,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: 'IDN',
|
||||
val: 9357861231.0,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: 'JPN',
|
||||
val: 6454620759.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Europe & Central Asia',
|
||||
val: 7667188460.0,
|
||||
children: [
|
||||
{
|
||||
name: 'RUS',
|
||||
val: 7667188460.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Latin America & Caribbean',
|
||||
val: 7752058955.0,
|
||||
children: [
|
||||
{
|
||||
name: 'BRA',
|
||||
val: 7752058955.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'North America',
|
||||
val: 13604468357.0,
|
||||
children: [
|
||||
{
|
||||
name: 'USA',
|
||||
val: 13604468357.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'South Asia',
|
||||
val: 57268340539.0,
|
||||
children: [
|
||||
{
|
||||
name: 'BGD',
|
||||
val: 5549261462.0,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: 'IND',
|
||||
val: 46023037597.0,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: 'PAK',
|
||||
val: 5696041480.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Sub-Saharan Africa',
|
||||
val: 5259800493.0,
|
||||
children: [
|
||||
{
|
||||
name: 'NGA',
|
||||
val: 5259800493.0,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -16,8 +16,7 @@
|
||||
"src/**/*.js",
|
||||
"src/**/*.jsx",
|
||||
"src/**/*.test.*",
|
||||
"src/**/*.stories.*"
|
||||
],
|
||||
"src/**/*.stories.*"],
|
||||
"references": [
|
||||
{ "path": "../../packages/superset-core" },
|
||||
{ "path": "../../packages/superset-ui-core" },
|
||||
|
||||
Reference in New Issue
Block a user