| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- /*
- * 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 } from '@superset-ui/core';
- import {
- DiligentChartPlugin,
- BuggyChartPlugin,
- ChartKeys,
- } from '../../../../superset-ui-core/test/chart/components/MockChartPlugins';
- import ResizableChartDemo from '../../shared/components/ResizableChartDemo';
- new DiligentChartPlugin().configure({ key: ChartKeys.DILIGENT }).register();
- new BuggyChartPlugin().configure({ key: ChartKeys.BUGGY }).register();
- const DEFAULT_QUERY_DATA = { data: ['foo', 'bar'] };
- export default {
- title: 'Others/SuperChart',
- decorators: [],
- };
- export const basic = ({ width, height }: { width: string; height: string }) => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- width={width}
- height={height}
- queriesData={[DEFAULT_QUERY_DATA]}
- formData={{ hi: 1 }}
- />
- );
- basic.args = {
- width: '100%',
- height: '100%',
- };
- basic.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const container50pct = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- width={width}
- height={height}
- queriesData={[DEFAULT_QUERY_DATA]}
- formData={{ hi: 1 }}
- />
- );
- container50pct.storyName = '50% of container';
- container50pct.args = {
- width: '50%',
- height: '50%',
- };
- container50pct.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const Resizable = () => (
- <ResizableChartDemo>
- {size => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- width={size.width}
- height={size.height}
- queriesData={[DEFAULT_QUERY_DATA]}
- />
- )}
- </ResizableChartDemo>
- );
- export const fixedWidth100height = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- height={height}
- width={width}
- queriesData={[DEFAULT_QUERY_DATA]}
- />
- );
- fixedWidth100height.storyName = 'fixed width, 100% height';
- fixedWidth100height.args = {
- width: '500',
- height: '100%',
- };
- fixedWidth100height.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const fixedHeight100Width = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- height={height}
- width={width}
- queriesData={[DEFAULT_QUERY_DATA]}
- />
- );
- fixedHeight100Width.storyName = 'fixed height, 100% width';
- fixedHeight100Width.args = {
- width: '100%',
- height: '300',
- };
- fixedHeight100Width.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const withErrorBoundary = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart
- chartType={ChartKeys.BUGGY}
- height={height}
- width={width}
- queriesData={[DEFAULT_QUERY_DATA]}
- />
- );
- withErrorBoundary.storyName = 'With Error Boundary';
- withErrorBoundary.args = {
- width: '500',
- height: '300',
- };
- withErrorBoundary.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const withWrapper = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart
- chartType={ChartKeys.DILIGENT}
- width={width}
- height={height}
- queriesData={[DEFAULT_QUERY_DATA]}
- Wrapper={({ children }) => (
- <div>
- <div style={{ margin: 10, position: 'fixed' }}>With wrapper!</div>
- {children}
- </div>
- )}
- />
- );
- withWrapper.storyName = 'With Wrapper';
- withWrapper.args = {
- width: '100%',
- height: '100%',
- };
- withWrapper.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const withNoResults = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart chartType={ChartKeys.DILIGENT} width={width} height={height} />
- );
- withNoResults.storyName = 'With no results';
- withNoResults.args = {
- width: '100%',
- height: '100%',
- };
- withNoResults.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const withNoResultsAndMedium = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart chartType={ChartKeys.DILIGENT} width={width} height={height} />
- );
- withNoResultsAndMedium.storyName = 'With no results and medium';
- withNoResultsAndMedium.args = {
- width: '400',
- height: '300',
- };
- withNoResultsAndMedium.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
- export const withNoResultsAndSmall = ({
- width,
- height,
- }: {
- width: string;
- height: string;
- }) => (
- <SuperChart chartType={ChartKeys.DILIGENT} width={width} height={height} />
- );
- withNoResultsAndSmall.storyName = 'With no results and small';
- withNoResultsAndSmall.args = {
- width: '150',
- height: '200',
- };
- withNoResultsAndSmall.argTypes = {
- width: { control: 'text', description: 'Vis width' },
- height: { control: 'text', description: 'Vis height' },
- };
|