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