github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/ui/dashboard/src/components/dashboards/charts/ColumnChart/index.stories.js (about)

     1  import ColumnChart from "./index";
     2  import { PanelStoryDecorator } from "../../../../utils/storybook";
     3  import { MultiTimeSeriesDefaults, MultiTimeSeriesGroupedDefaults, SingleTimeSeriesDefaults, MultiTimeSeriesCrosstabDefaults } from "../Chart/index.stories";
     4  
     5  const story = {
     6    title: "Charts/Column",
     7    component: ColumnChart.component,
     8  };
     9  
    10  export default story;
    11  
    12  const Template = (args) => (
    13    <PanelStoryDecorator
    14      definition={{ ...args, display_type: "column" }}
    15      panelType="chart"
    16    />
    17  );
    18  
    19  export const Loading = Template.bind({});
    20  Loading.args = {
    21    data: null,
    22  };
    23  
    24  export const Error = Template.bind({});
    25  Error.args = {
    26    data: null,
    27    error: "Something went wrong!",
    28  };
    29  
    30  export const SingleSeries = Template.bind({});
    31  SingleSeries.storyName = "Single Series";
    32  SingleSeries.args = {
    33    data: {
    34      columns: [
    35        { name: "Type", data_type: "TEXT" },
    36        { name: "Count", data_type: "INT8" },
    37      ],
    38      rows: [
    39        { Type: "User", Count: 12 },
    40        { Type: "Policy", Count: 93 },
    41        { Type: "Role", Count: 48 },
    42      ],
    43    },
    44  };
    45  
    46  export const LargeSeries = Template.bind({});
    47  LargeSeries.args = {
    48    data: {
    49      columns: [
    50        { name: "Region", data_type: "TEXT" },
    51        { name: "Total", data_type: "INT8" },
    52      ],
    53      rows: [
    54        { Region: "us-east-1", Total: 14 },
    55        { Region: "eu-central-1", Total: 6 },
    56        { Region: "ap-south-1", Total: 4 },
    57        { Region: "ap-southeast-1", Total: 3 },
    58        { Region: "ap-southeast-2", Total: 2 },
    59        { Region: "ca-central-1", Total: 2 },
    60        { Region: "eu-north-1", Total: 2 },
    61        { Region: "eu-west-1", Total: 1 },
    62        { Region: "eu-west-2", Total: 1 },
    63        { Region: "eu-west-3", Total: 1 },
    64        { Region: "sa-east-1", Total: 1 },
    65        { Region: "us-east-2", Total: 1 },
    66        { Region: "us-west-1", Total: 1 },
    67        { Region: "ap-northeast-1", Total: 1 },
    68        { Region: "us-west-2", Total: 1 },
    69        { Region: "ap-northeast-2", Total: 1 },
    70      ],
    71    },
    72  };
    73  
    74  export const MultiSeriesStacked = Template.bind({});
    75  MultiSeriesStacked.storyName = "Multi-Series (stacked)";
    76  MultiSeriesStacked.args = {
    77    data: {
    78      columns: [
    79        { name: "Country", data_type: "TEXT" },
    80        { name: "Men", data_type: "INT8" },
    81        { name: "Women", data_type: "INT8" },
    82        { name: "Children", data_type: "INT8" },
    83      ],
    84      rows: [
    85        { Country: "England", Men: 16000000, Women: 13000000, Children: 8000000 },
    86        { Country: "Scotland", Men: 8000000, Women: 7000000, Children: 3000000 },
    87        {
    88          Country: "Wales",
    89          Men: 5000000,
    90          Women: 3000000,
    91          Children: 2500000,
    92        },
    93        {
    94          Country: "Northern Ireland",
    95          Men: 3000000,
    96          Women: 2000000,
    97          Children: 1000000,
    98        },
    99      ],
   100    },
   101    properties: {
   102      grouping: "stack",
   103    },
   104  };
   105  
   106  export const MultiSeriesGrouped = Template.bind({});
   107  MultiSeriesGrouped.storyName = "Multi-Series (grouped)";
   108  MultiSeriesGrouped.args = {
   109    data: {
   110      columns: [
   111        { name: "Country", data_type: "TEXT" },
   112        { name: "Men", data_type: "INT8" },
   113        { name: "Women", data_type: "INT8" },
   114        { name: "Children", data_type: "INT8" },
   115      ],
   116      rows: [
   117        { Country: "England", Men: 16000000, Women: 13000000, Children: 8000000 },
   118        { Country: "Scotland", Men: 8000000, Women: 7000000, Children: 3000000 },
   119        {
   120          Country: "Wales",
   121          Men: 5000000,
   122          Women: 3000000,
   123          Children: 2500000,
   124        },
   125        {
   126          Country: "Northern Ireland",
   127          Men: 3000000,
   128          Women: 2000000,
   129          Children: 1000000,
   130        },
   131      ],
   132    },
   133    properties: {
   134      grouping: "compare",
   135    },
   136  };
   137  
   138  export const MultiSeriesOverrides = Template.bind({});
   139  MultiSeriesOverrides.storyName = "Multi-Series with Series Overrides";
   140  MultiSeriesOverrides.args = {
   141    data: {
   142      columns: [
   143        { name: "Country", data_type: "TEXT" },
   144        { name: "Men", data_type: "INT8" },
   145        { name: "Women", data_type: "INT8" },
   146        { name: "Children", data_type: "INT8" },
   147      ],
   148      rows: [
   149        { Country: "England", Men: 16000000, Women: 13000000, Children: 8000000 },
   150        { Country: "Scotland", Men: 8000000, Women: 7000000, Children: 3000000 },
   151        {
   152          Country: "Wales",
   153          Men: 5000000,
   154          Women: 3000000,
   155          Children: 2500000,
   156        },
   157        {
   158          Country: "Northern Ireland",
   159          Men: 3000000,
   160          Women: 2000000,
   161          Children: 1000000,
   162        },
   163      ],
   164    },
   165    properties: {
   166      series: {
   167        Children: {
   168          title: "Kids",
   169          color: "green",
   170        },
   171      },
   172    },
   173  };
   174  
   175  export const SingleSeriesLegend = Template.bind({});
   176  SingleSeriesLegend.storyName = "Single Series with Legend";
   177  SingleSeriesLegend.args = {
   178    data: {
   179      columns: [
   180        { name: "Type", data_type: "TEXT" },
   181        { name: "Count", data_type: "INT8" },
   182      ],
   183      rows: [
   184        { Type: "User", Count: 12 },
   185        { Type: "Policy", Count: 93 },
   186        { Type: "Role", Count: 48 },
   187      ],
   188    },
   189    properties: {
   190      legend: {
   191        display: "all",
   192      },
   193    },
   194  };
   195  
   196  export const SingleSeriesLegendPosition = Template.bind({});
   197  SingleSeriesLegendPosition.storyName = "Single Series With Legend At Bottom";
   198  SingleSeriesLegendPosition.args = {
   199    data: {
   200      columns: [
   201        { name: "Type", data_type: "TEXT" },
   202        { name: "Count", data_type: "INT8" },
   203      ],
   204      rows: [
   205        { Type: "User", Count: 12 },
   206        { Type: "Policy", Count: 93 },
   207        { Type: "Role", Count: 48 },
   208      ],
   209    },
   210    properties: {
   211      legend: {
   212        display: "all",
   213        position: "bottom",
   214      },
   215    },
   216  };
   217  
   218  export const SingleSeriesXAxisTitle = Template.bind({});
   219  SingleSeriesXAxisTitle.storyName = "Single Series with X Axis Title";
   220  SingleSeriesXAxisTitle.args = {
   221    data: {
   222      columns: [
   223        { name: "Type", data_type: "TEXT" },
   224        { name: "Count", data_type: "INT8" },
   225      ],
   226      rows: [
   227        { Type: "User", Count: 12 },
   228        { Type: "Policy", Count: 93 },
   229        { Type: "Role", Count: 48 },
   230      ],
   231    },
   232    properties: {
   233      axes: {
   234        x: {
   235          title: {
   236            display: "all",
   237            value: "I am a the X Axis title",
   238          },
   239        },
   240      },
   241    },
   242  };
   243  
   244  export const SingleSeriesXAxisNoLabels = Template.bind({});
   245  SingleSeriesXAxisNoLabels.storyName = "Single Series with no X Axis Labels";
   246  SingleSeriesXAxisNoLabels.args = {
   247    data: {
   248      columns: [
   249        { name: "Type", data_type: "TEXT" },
   250        { name: "Count", data_type: "INT8" },
   251      ],
   252      rows: [
   253        { Type: "User", Count: 12 },
   254        { Type: "Policy", Count: 93 },
   255        { Type: "Role", Count: 48 },
   256      ],
   257    },
   258    properties: {
   259      axes: {
   260        x: {
   261          labels: {
   262            display: "none",
   263          },
   264        },
   265      },
   266    },
   267  };
   268  
   269  export const SingleSeriesYAxisNoLabels = Template.bind({});
   270  SingleSeriesYAxisNoLabels.storyName = "Single Series with no Y Axis Labels";
   271  SingleSeriesYAxisNoLabels.args = {
   272    data: {
   273      columns: [
   274        { name: "Type", data_type: "TEXT" },
   275        { name: "Count", data_type: "INT8" },
   276      ],
   277      rows: [
   278        { Type: "User", Count: 12 },
   279        { Type: "Policy", Count: 93 },
   280        { Type: "Role", Count: 48 },
   281      ],
   282    },
   283    properties: {
   284      axes: {
   285        y: {
   286          labels: {
   287            display: "none",
   288          },
   289        },
   290      },
   291    },
   292  };
   293  
   294  export const TimeSeries = Template.bind({});
   295  TimeSeries.storyName = "Single Time Series";
   296  TimeSeries.args = SingleTimeSeriesDefaults;
   297  
   298  export const MultiTimeSeries = Template.bind({});
   299  MultiTimeSeries.storyName = "Multiple Time Series with Overrides (stacked)";
   300  MultiTimeSeries.args = MultiTimeSeriesDefaults;
   301  
   302  export const MultiTimeSeriesGrouped = Template.bind({});
   303  MultiTimeSeriesGrouped.storyName = "Multiple Time Series (grouped)";
   304  MultiTimeSeriesGrouped.args = MultiTimeSeriesGroupedDefaults;
   305  
   306  export const MultiTimeSeriesCrosstab = Template.bind({});
   307  MultiTimeSeriesCrosstab.storyName = "Multiple Time Series (crosstabbed)";
   308  MultiTimeSeriesCrosstab.args = MultiTimeSeriesCrosstabDefaults;