In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. Once 'highcharts' and 'highcharts-react-official are installed into your repo, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
See the highcharts API docs for a comprehensive look at what is possible.
In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
Use custom CSS with classes or inline styles (as shown in these docs) to customize the appearance of prefix and suffix units.
<% data1 = [{ name: 'Data Used', y: 32 }] %> <% data2 = [{ name: 'Sales to Date', y: 65 }] %> <% chart_options_1 = { title: { text: "Data Usage", }, series: [{ data: data1 }], plotOptions: { solidgauge: { dataLabels: { format: '<span class="fix">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">GB</span>', }, }, }, } %> <% chart_options_2 = { title: { text: "Sales Goal", }, series: [{ data: data2 }], plotOptions: { solidgauge: { dataLabels: { format: '<span y="28" style="fill: #687887; font-size: 16px;">$</span>' + '<span class="fix" y="38">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">k</span>', }, }, }, } %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_1 }) %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_2 }) %>
<% data = [{ name: "Capacity", y: 75 }] %> <% chart_options = { title: { text: "Seating Capacity", }, series: [{ data: data }], pane: { startAngle: 0, endAngle: 360, }, plotOptions: { solidgauge: { dataLabels: { format: '<span class="fix">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">%</span>', }, }, }, } %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %>
By default, Highcharts set min to 0 and max to 100 but this can be customized if needed as shown here.
<% data = [{ name: "Rating", y: 4.5 }] %> <% chart_options = { title: { text: "Product Rating", }, yAxis: { min: 0, max: 5, lineWidth: 0, tickWidth: 0, minorTickInterval: nil, tickAmount: 2, tickPositions: [0, 5], labels: { y: 26, enabled: true, style: { color: '#C1CDD6', fontWeight:'700', } }, }, series: [{ data: data }], } %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %>
The Gauge chart resizes dynamically to fit whatever element it's placed within.
Note: set overflow to hidden on the parent element when nesting gauges inside of flex items to best respond to shrinking screens.
<% chart_options = { series: [{ data:[{ name: "Point 1", y: 100 }] }] } %> <% chart_options_1 = { series: [{ data:[{ name: "Point 2", y: 75 }] }] } %> <% chart_options_2 = { series: [{ data:[{ name: "Point 3", y: 50 }] }] } %> <% chart_options_3 = { series: [{ data:[{ name: "Point 4", y: 25 }] }] } %> <%= pb_rails("flex", props: {wrap: true, align: "center"}) do %> <%= pb_rails("flex/flex_item", props: {fixed_size: "400px", overflow: "hidden", shrink: true }) do %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %> <% end %> <%= pb_rails("flex/flex_item", props: {fixed_size: "300px", overflow: "hidden", shrink: true }) do %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_1 }) %> <% end %> <%= pb_rails("flex/flex_item", props: {fixed_size: "200px", overflow: "hidden", shrink: true }) do %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_2 }) %> <% end %> <%= pb_rails("flex/flex_item", props: {fixed_size: "155px", overflow: "hidden", shrink: true }) do %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_3 }) %> <% end %> <% end %>
<% chart_options = { title: { text: "Fixed Height in Pixels", }, chart: { height: "400", }, series: [{ data: [{ name: "Pixels", y: 400 }] }], plotOptions: { solidgauge: { dataLabels: { format: '<span class="fix">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">px</span>', }, }, }, } %> <% chart_options_1 = { title: { text: "Height as Percentage of Width", }, chart: { height: "45%", }, series: [{ data: [{ name: "Percentage", y: 45 }] }], plotOptions: { solidgauge: { dataLabels: { format: '<span class="fix">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">%</span>', }, }, }, } %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options_1 }) %>
Highcharts allows for any custom colors to be used. Custom data colors allow for color customization to match the needs of business requirements.
For React, pass the option plotOptions.solidgauge.borderColor with a Playbook token like colors. + data_1 | data_2 | data_3 | data_4 | data_5 | data_6 | data_7 | data_8. HEX colors are also available eg: #CA0095
For Rails, the option plotOptions.solidgauge.borderColor can only be used with HEX values as shown.
We are able to wrap the Highcharts Gauge kit within Playbook kits (such as Flex and Card components).
<% chart_options = { series:[{data:[{ name: "Name", y: 10 }]}], chart: { height: "150", }, plotOptions: { series: { animation: false, }, solidgauge: { dataLabels: { format: '<span class="fix">{y:,f}</span>' + '<span style="fill: #687887; font-size: 27px;">%</span>', }, }, }, } %> <%= pb_rails("flex", props: {wrap: true, padding: "xl", gap: "sm"}) do %> <%= pb_rails("flex/flex_item", props: {flex: 1, grow: true }) do %> <%= pb_rails("card", props: {max_width: "xs", padding: "md", }) do %> <%= pb_rails("title", props: {padding_bottom: "sm", size: 4, text: "Abandoned Calls" })%> <%= pb_rails("flex", props: {align: "stretch"}) do %> <%= pb_rails("flex", props: {margin_right: "sm", orientation: "column"}) do %> <%= pb_rails("body", props: {color: "light", padding_bottom: "sm",text: "Total Abandoned"}) %> <%= pb_rails("flex", props: {align: "baseline", padding_bottom: "sx"}) do %> <%= pb_rails("title", props: {size: 1, text: "39"})%> <%= pb_rails("title", props: {color: "light", size: 3, text: "calls"}) %> <% end %> <%= pb_rails("caption", props: {size: "xs", text: "of 390" }) %> <%end %> <%= pb_rails("section_separator", props: {align_self: "stretch", margin_right: "sm", orientation: "vertical" }) %> <%= pb_rails("flex", props: {orientation: "column", wrap: true}) do %> <%= pb_rails("body", props: {color: "light", text: "% Abandoned"}) %> <%= pb_rails("flex", props: {wrap: true}) do %> <%= pb_rails("flex/flex_item", props: {fixed_size: "150px", overflow: "hidden", shrink: true}) do %> <%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %> <% end %> <% end %> <% end %> <%end %> <% end %> <% end %> <% end %>
| Props | Type | Values |
|---|---|---|
gap |
array
|
none
xxs
xs
sm
md
lg
xl
|
max_width |
array
|
0%
xs
sm
md
lg
xl
xxl
0
none
100%
|
min_width |
array
|
0%
xs
sm
md
lg
xl
xxl
0
none
100%
|
width |
array
|
0%
xs
sm
md
lg
xl
xxl
0
none
100%
|
z_index |
array
|
1
2
3
4
5
6
7
8
9
10
max
|
number_spacing |
array
|
tabular
|
shadow |
array
|
none
deep
deeper
deepest
|
line_height |
array
|
tightest
tighter
tight
normal
loose
looser
loosest
|
display |
array
|
block
inline_block
inline
flex
inline_flex
none
grid
|
cursor |
array
|
auto
default
none
contextMenu
help
pointer
progress
wait
cell
crosshair
text
verticalText
alias
copy
move
noDrop
notAllowed
grab
grabbing
eResize
nResize
neResize
nwResize
sResize
seResize
swResize
wResize
ewResize
nsResize
neswResize
nwseResize
colResize
rowResize
allScroll
zoomIn
zoomOut
|
flex_direction |
array
|
row
column
rowReverse
columnReverse
|
flex_wrap |
array
|
wrap
nowrap
wrapReverse
|
justify_content |
array
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
justify_self |
array
|
auto
start
end
center
stretch
|
align_items |
array
|
flexStart
flexEnd
start
end
center
baseline
stretch
|
align_content |
array
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
align_self |
array
|
auto
start
end
center
stretch
baseline
|
flex |
array
|
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none
|
flex_grow |
array
|
1
0
|
flex_shrink |
array
|
1
0
|
order |
array
|
1
2
3
4
5
6
7
8
9
10
11
12
|
position |
array
|
relative
absolute
fixed
sticky
|
hover |
array
|
|
border_radius |
array
|
none
xs
sm
md
lg
xl
rounded
|
text_align |
array
|
start
end
left
right
center
justify
justify-all
match-parent
|
overflow |
array
|
visible
hidden
scroll
auto
|
truncate |
array
|
1
2
3
4
5
|
left |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
top |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
right |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
bottom |
array
|
0
xxs
xs
sm
md
lg
xl
auto
initial
inherit
|
vertical_align |
array
|
baseline
super
top
middle
bottom
sub
text-top
text-bottom
|
height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
min_height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
max_height |
array
|
auto
xs
sm
md
lg
xl
xxl
xxxl
|
overflow_x |
array
|
visible
hidden
scroll
auto
|
overflow_y |
array
|
visible
hidden
scroll
auto
|
margin |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
classname |
string
|
|
dark |
boolean
|
|
column_gap |
string
|
|
row_gap |
string
|
|
group_hover |
boolean
|
|
id |
string
|
|
data |
hashprop
|
|
aria |
hashprop
|
|
html_options |
hashprop
|
|
children |
proc
|
|
style |
hashprop
|
| Props | Type | Values | Default |
|---|---|---|---|
options |
string
|