github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/ui/dashboard/src/components/dashboards/charts/LineChart/index.stories.js (about) 1 import LineChart from "./index"; 2 import { PanelStoryDecorator } from "../../../../utils/storybook"; 3 import { MultiTimeSeriesDefaults, SingleTimeSeriesDefaults, MultiTimeSeriesCrosstabDefaults } from "../Chart/index.stories"; 4 5 const story = { 6 title: "Charts/Line", 7 component: LineChart.component, 8 }; 9 10 export default story; 11 12 const Template = (args) => ( 13 <PanelStoryDecorator 14 definition={{ ...args, display_type: "line" }} 15 panelType="chart" 16 /> 17 ); 18 19 export const Loading = Template.bind({}); 20 Loading.args = { 21 loading: true, 22 }; 23 24 export const Error = Template.bind({}); 25 Error.args = { 26 loading: false, 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 MultiSeries = Template.bind({}); 75 MultiSeries.storyName = "Multi-Series"; 76 MultiSeries.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 }; 102 103 export const MultiSeriesOverrides = Template.bind({}); 104 MultiSeriesOverrides.storyName = "Multi-Series with Series Overrides"; 105 MultiSeriesOverrides.args = { 106 data: { 107 columns: [ 108 { name: "Country", data_type: "TEXT" }, 109 { name: "Men", data_type: "INT8" }, 110 { name: "Women", data_type: "INT8" }, 111 { name: "Children", data_type: "INT8" }, 112 ], 113 rows: [ 114 { Country: "England", Men: 16000000, Women: 13000000, Children: 8000000 }, 115 { Country: "Scotland", Men: 8000000, Women: 7000000, Children: 3000000 }, 116 { 117 Country: "Wales", 118 Men: 5000000, 119 Women: 3000000, 120 Children: 2500000, 121 }, 122 { 123 Country: "Northern Ireland", 124 Men: 3000000, 125 Women: 2000000, 126 Children: 1000000, 127 }, 128 ], 129 }, 130 properties: { 131 series: { 132 Children: { 133 title: "Kids", 134 color: "green", 135 }, 136 }, 137 }, 138 }; 139 140 export const SingleSeriesLegend = Template.bind({}); 141 SingleSeriesLegend.storyName = "Single Series with Legend"; 142 SingleSeriesLegend.args = { 143 data: { 144 columns: [ 145 { name: "Type", data_type: "TEXT" }, 146 { name: "Count", data_type: "INT8" }, 147 ], 148 rows: [ 149 { Type: "User", Count: 12 }, 150 { Type: "Policy", Count: 93 }, 151 { Type: "Role", Count: 48 }, 152 ], 153 }, 154 properties: { 155 legend: { 156 display: "all", 157 }, 158 }, 159 }; 160 161 export const SingleSeriesLegendPosition = Template.bind({}); 162 SingleSeriesLegendPosition.storyName = "Single Series With Legend At Bottom"; 163 SingleSeriesLegendPosition.args = { 164 data: { 165 columns: [ 166 { name: "Type", data_type: "TEXT" }, 167 { name: "Count", data_type: "INT8" }, 168 ], 169 rows: [ 170 { Type: "User", Count: 12 }, 171 { Type: "Policy", Count: 93 }, 172 { Type: "Role", Count: 48 }, 173 ], 174 }, 175 properties: { 176 legend: { 177 display: "all", 178 position: "bottom", 179 }, 180 }, 181 }; 182 183 export const SingleSeriesXAxisTitle = Template.bind({}); 184 SingleSeriesXAxisTitle.storyName = "Single Series with X Axis Title"; 185 SingleSeriesXAxisTitle.args = { 186 data: { 187 columns: [ 188 { name: "Type", data_type: "TEXT" }, 189 { name: "Count", data_type: "INT8" }, 190 ], 191 rows: [ 192 { Type: "User", Count: 12 }, 193 { Type: "Policy", Count: 93 }, 194 { Type: "Role", Count: 48 }, 195 ], 196 }, 197 properties: { 198 axes: { 199 x: { 200 title: { 201 display: "all", 202 value: "I am a the X Axis title", 203 }, 204 }, 205 }, 206 }, 207 }; 208 209 export const SingleSeriesXAxisNoLabels = Template.bind({}); 210 SingleSeriesXAxisNoLabels.storyName = "Single Series with no X Axis Labels"; 211 SingleSeriesXAxisNoLabels.args = { 212 data: { 213 columns: [ 214 { name: "Type", data_type: "TEXT" }, 215 { name: "Count", data_type: "INT8" }, 216 ], 217 rows: [ 218 { Type: "User", Count: 12 }, 219 { Type: "Policy", Count: 93 }, 220 { Type: "Role", Count: 48 }, 221 ], 222 }, 223 properties: { 224 axes: { 225 x: { 226 labels: { 227 display: "none", 228 }, 229 }, 230 }, 231 }, 232 }; 233 234 export const SingleSeriesYAxisNoLabels = Template.bind({}); 235 SingleSeriesYAxisNoLabels.storyName = "Single Series with no Y Axis Labels"; 236 SingleSeriesYAxisNoLabels.args = { 237 data: { 238 columns: [ 239 { name: "Type", data_type: "TEXT" }, 240 { name: "Count", data_type: "INT8" }, 241 ], 242 rows: [ 243 { Type: "User", Count: 12 }, 244 { Type: "Policy", Count: 93 }, 245 { Type: "Role", Count: 48 }, 246 ], 247 }, 248 properties: { 249 axes: { 250 y: { 251 labels: { 252 display: "none", 253 }, 254 }, 255 }, 256 }, 257 }; 258 259 export const TimeSeries = Template.bind({}); 260 TimeSeries.storyName = "Single Time Series"; 261 TimeSeries.args = SingleTimeSeriesDefaults; 262 263 // Line charts cannot stack, use Area for that 264 export const MultiTimeSeries = Template.bind({}); 265 MultiTimeSeries.storyName = "Multiple Time Series"; 266 MultiTimeSeries.args = MultiTimeSeriesDefaults; 267 268 export const MultiTimeSeriesCrosstab = Template.bind({}); 269 MultiTimeSeriesCrosstab.storyName = "Multiple Time Series (crosstabbed)"; 270 MultiTimeSeriesCrosstab.args = MultiTimeSeriesCrosstabDefaults;