@@ -13,10 +13,14 @@ import { Axis, BarSeries, Chart, Position, ScaleType, Settings } from '@elastic/
1313
1414import type { ChartsStory } from '../../types' ;
1515import { useBaseTheme } from '../../use_base_theme' ;
16+ import { customKnobs } from '../utils/knobs' ;
1617
1718const data = [
18- { x : 'com.example.something.host.23' , y : 12 } ,
19- { x : 'com.example.something.host.11' , y : 8 } ,
19+ {
20+ x : 'com.example.something.host.23com.example.something.com.example.something' ,
21+ y : 12 ,
22+ } ,
23+ { x : 'com.example.something.host.11com.example.something.host.11' , y : 8 } ,
2024 { x : 'com.example.something.host.07' , y : 17 } ,
2125 { x : 'com.example.something.host.02' , y : 5 } ,
2226 { x : 'com.example.something.worker.04' , y : 9 } ,
@@ -37,20 +41,35 @@ function parseThemeSize(raw: string): number | string | undefined {
3741}
3842
3943export const Example : ChartsStory = ( _ , { title, description } ) => {
40- const maxLength = parseThemeSize ( text ( 'maxLength' , '120' ) ) ;
41- const truncate = select < EllipsisPosition > ( 'truncate' , { end : 'end' , start : 'start' , middle : 'middle' } , 'middle' ) ;
42- const rotation = select ( 'Chart rotation' , { '0°' : 0 , '90°' : 90 , '-90°' : - 90 } , 90 ) ;
43-
44- const tickLabel = {
45- ...( maxLength !== undefined ? { maxLength } : { } ) ,
46- truncate,
47- } ;
44+ const xMaxLength = parseThemeSize ( text ( 'Max length (X)' , '' ) ) ;
45+ const xTruncate = select < EllipsisPosition > (
46+ 'Truncate (X)' ,
47+ { end : 'end' , start : 'start' , middle : 'middle' } ,
48+ 'middle' ,
49+ ) ;
50+ const yMaxLength = parseThemeSize ( text ( 'Max length (Y)' , '120' ) ) ;
51+ const yTruncate = select < EllipsisPosition > (
52+ 'Truncate (Y)' ,
53+ { end : 'end' , start : 'start' , middle : 'middle' } ,
54+ 'middle' ,
55+ ) ;
56+ const rotation = customKnobs . enum . rotation ( 'Chart rotation' , 90 ) ;
4857
4958 return (
5059 < Chart title = { title } description = { description } >
5160 < Settings baseTheme = { useBaseTheme ( ) } rotation = { rotation } />
52- < Axis id = "bottom" position = { Position . Bottom } title = "Count" style = { { tickLabel } } />
53- < Axis id = "left" position = { Position . Left } title = "Team" style = { { tickLabel } } />
61+ < Axis
62+ id = "bottom"
63+ position = { Position . Bottom }
64+ title = "Count"
65+ style = { { tickLabel : { maxLength : xMaxLength , truncate : xTruncate } } }
66+ />
67+ < Axis
68+ id = "left"
69+ position = { Position . Left }
70+ title = "Team"
71+ style = { { tickLabel : { maxLength : yMaxLength , truncate : yTruncate } } }
72+ />
5473
5574 < BarSeries
5675 id = "bars"
0 commit comments