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.
<% data = [ { name: "Waiting for Calls", y: 41, }, { name: "On Call", y: 49, }, { name: "After Call", y: 10, }, ] %> <% chart_options = { series: [{ data: data, innerSize: '100%', borderWidth: '20', }], } %> <div style="position: relative;"> <%= pb_rails("pb_circle_chart", props: { options: chart_options }) %> <div class="pb-circle-chart-block" style="position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; z-index: 1; text-align: center; pointer-events: none;"> <%= pb_rails("title", props: { size: 1, tag: "div", text: "83" }) %> </div> </div>
Custom data colors allow for color customization to match the needs of business requirements.
For React, import the colors from Playbook's tokens, then set custom colors in the plotOptions.pie.colors array using the desired color variables.
For Rails, only HEX colors can be used eg: #CA0095
<% data = [ { name: "Waiting for Calls", y: 41, }, { name: "On Call", y: 49, }, { name: "After Call", y: 10, }, ] %> <% chart_options = { series: [{ data: data }], plotOptions: { pie: { colors: ["#144075", "#1CA05C", "#F9BB00"], }, }, } %> <%= pb_rails("pb_circle_chart", props: { options: chart_options }) %>
<% data = [ { name: "Facebook", y: 2498, }, { name: "YouTube", y: 2000, }, { name: "WhatsApp", y: 2000, }, { name: "Facebook Messenger", y: 1300, }, { name: "WeChat", y: 1165, }, { name: "Instagram", y: 1000, }, { name: "Tik Tok", y: 800, },] %> <% chart_options = { series: [{ data: data }], plotOptions: { pie: { dataLabels: { enabled: true, }, }, }, } %> <%= pb_rails("pb_circle_chart", props: { options: chart_options }) %>
Layout options from Highcharts:
align Type: String | Values: left | center | right (defaults to center)
verticalAlign Type: String | Values: top | middle | bottom (defaults to bottom)
layout Type: String | Values: horizontal | vertical | proximate (defaults to horizontal)
x Type: Number (defaults to 0)
y Type: Number (defaults to 0)
layout determines the position of the legend items
layout: proximate will place the legend items as close as possible to the graphs they're representing. It will also determine whether to place the legend above/below or on the side of the plot area, if the legend is in a corner.
x offsets the legend relative to its horizontal alignment. Negative x moves it to the left, positive x moves it to the right
y offsets the legend relative to its vertical alignment. Negative y moves it up, positive y moves it down.
<% data_first = [{ name: 'Bugs', y: 8, }, { name: 'Chores', y: 1, }, { name: 'Stories', y: 12, }] %> <% data_second = [{ name: 'Bugs', y: 8, }, { name: 'Chores', y: 1, }, { name: 'Stories', y: 12, }] %> <% data_third = [{ name: 'Queued', y: 7, }, { name: 'In Progress', y: 6, }, { name: 'Validation', y: 3, }, { name: 'Done', y: 6, }, ] %> <% chart_options_first = { title: { text: "Alignment of Legend" }, series: [{ data: data_first }], legend: { align: 'right', verticalAlign: 'top' }, plotOptions: { pie: { showInLegend: true } } } %> <% chart_options_second = { title: { text: "Layout of Legend" }, series: [{ data: data_second }], legend: { layout: 'vertical' }, plotOptions: { pie: { showInLegend: true } } } %> <% chart_options_third = { title: { text: "Offset of Legend" }, series: [{ data: data_third }], legend: { layout: 'vertical', x: 100, y: 10 }, plotOptions: { pie: { showInLegend: true } } } %> <%= pb_rails("title", props: { size: 4, text: "align | verticalAlign", padding_y:"sm" }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_first }) %> <%= pb_rails("title", props: { size: 4, text: "layout", padding_y:"sm" }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_second }) %> <%= pb_rails("title", props: { size: 4, text: "x | y", padding_y:"sm" }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_third }) %>
<% data = [ { name: 'Facebook', y: 2498, }, { name: 'YouTube', y: 2000, }, { name: 'WhatsApp', y: 2000, }, { name: 'Facebook Messenger', y: 1300, }, { name: 'WeChat', y: 1165, }, { name: 'Instagram', y: 1000, }, { name: 'Tik Tok', y: 800, }, ] %> <% chart_options = { series: [{ data: data }], title: { text: "Active Users on Social Media" }, } %> <%= pb_rails("pb_circle_chart", props: { options: chart_options }) %>
<% data_first = [ { name: 'Bugs', y: 8, }, { name: 'Chores', y: 1, }, { name: 'Stories', y: 12, }, ] %> <% data_second = [ { name: 'Queued', y: 7, }, { name: 'In Progress', y: 6, }, { name: 'Validation', y: 3, }, { name: 'Done', y: 6, }, ] %> <% data_third = [ { name: '1 Point Tickets', y: 2, }, { name: '3 Point Tickets', y: 5, }, { name: '5 Point Tickets', y: 6, }, { name: '8 Point Tickets', y: 3, }, { name: '13 Point Tickets', y: 1, }, ] %> <% data_fourth = [ { name: 'Facebook', y: 2498, }, { name: 'YouTube', y: 2000, }, { name: 'WhatsApp', y: 2000, }, { name: 'Facebook Messenger', y: 1300, }, { name: 'WeChat', y: 1165, }, { name: 'Instagram', y: 1000, }, { name: 'Tik Tok', y: 800, }, ] %> <% chart_options_small = { series: [{ data: data_first, innerSize: '35%' }], } %> <% chart_options_md = { series: [{ data: data_second, innerSize: '50%' }], } %> <% chart_options_lg = { series: [{ data: data_third, innerSize: '85%' }], } %> <% chart_options_xl = { series: [{ data: data_fourth, innerSize: '0%' }], } %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_small }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_md }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_lg }) %> <%= pb_rails("pb_circle_chart", props: { options: chart_options_xl }) %>
Tooltip options from Highcharts:
headerFormat Type: String | when set to null will disable the header.
pointFormat Type: String | defines the HTML template for each data point and supports custom HTML when useHTML is enabled.
useHTML Type: boolean (default false) | enables HTML rendering in tooltips.
{point.name} and {point.y} are useful values that can be referenced for each point in the graph.
<% data = [ { name: 'Waiting for Calls', y: 41, }, { name: 'On Call', y: 49, }, { name: 'After Call', y: 10, }, ] %> <% chart_options = { series: [{ data: data }], tooltip: { headerFormat: nil, pointFormat: '<p>Custom tooltip for {point.name} <br/>with value: {point.y}</p>', useHTML: true, }, } %> <%= pb_rails("pb_circle_chart", props: { options: chart_options }) %>
| 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
|