55const lcjs = require ( '@lightningchart/lcjs' )
66
77// Extract required parts from LightningChartJS.
8- const { PyramidChartTypes, PyramidLabelSide, SliceLabelFormatters, lightningChart, LegendBoxBuilders, Themes } = lcjs
8+ const { PyramidChartTypes, PyramidLabelSide, PyramidSliceModes , SliceLabelFormatters, lightningChart, LegendBoxBuilders, Themes } = lcjs
99
10- // Create a Pyramid chart
11- const pyramid = lightningChart ( {
10+ const lc = lightningChart ( {
1211 resourcesBaseUrl : new URL ( document . head . baseURI ) . origin + new URL ( document . head . baseURI ) . pathname + 'resources/' ,
1312 } )
14- . Pyramid ( {
15- theme : Themes [ new URLSearchParams ( window . location . search ) . get ( 'theme' ) || 'darkGold' ] || undefined ,
16- type : PyramidChartTypes . LabelsOnSides ,
17- } )
13+ const dashboard = lc . Dashboard ( {
14+ numberOfColumns : 2 ,
15+ numberOfRows : 1 ,
16+ theme : Themes [ new URLSearchParams ( window . location . search ) . get ( 'theme' ) || 'darkGold' ] || undefined ,
17+ } )
18+
19+ const pyramid1 = dashboard
20+ . createPyramidChart ( { columnIndex : 0 , rowIndex : 0 , type : PyramidChartTypes . LabelsOnSides } )
21+ . setTitle ( 'Company staff growth' )
22+ . setSliceGap ( 5 )
23+ . setLabelSide ( PyramidLabelSide . Left )
24+ . setSliceMode ( PyramidSliceModes . VariableWidth )
25+
26+ const pyramid2 = dashboard
27+ . createPyramidChart ( { columnIndex : 1 , rowIndex : 0 , type : PyramidChartTypes . LabelsOnSides } )
1828 . setTitle ( 'Company staff growth' )
19- . setNeckWidth ( 80 )
2029 . setSliceGap ( 5 )
21- . setPadding ( { bottom : 45 } )
2230 . setLabelSide ( PyramidLabelSide . Right )
31+ . setSliceMode ( PyramidSliceModes . VariableHeight )
2332
2433// Data for slices
2534const data = [
@@ -40,20 +49,9 @@ const data = [
4049 value : 17 ,
4150 } ,
4251]
43- // Add data to the slices
44- pyramid . addSlices ( data )
45-
46- // Set formatter of Slice Labels
47- pyramid . setLabelFormatter ( SliceLabelFormatters . NamePlusValue )
4852
49- // Add LegendBox and define the position in the chart
50- const lb = pyramid
51- . addLegendBox ( LegendBoxBuilders . HorizontalLegendBox )
52- // Dispose example UI elements automatically if they take too much space. This is to avoid bad UI on mobile / etc. devices.
53- . setAutoDispose ( {
54- type : 'max-width' ,
55- maxWidth : 0.8 ,
56- } )
53+ pyramid1 . addSlices ( data )
54+ pyramid1 . setLabelFormatter ( SliceLabelFormatters . NamePlusValue )
5755
58- // Add the Pyramid to the LegendBox and disable the button click functionality.
59- lb . add ( pyramid , { toggleVisibilityOnClick : false } )
56+ pyramid2 . addSlices ( data )
57+ pyramid2 . setLabelFormatter ( SliceLabelFormatters . NamePlusValue )
0 commit comments