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.
NOTE: All chart kits are available through a separate entrypoint to keep Highcharts optional. Import them using:
import { PbCircleChart } from 'playbook-ui/charts'
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 |
|---|---|---|
align_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
align_items |
enum | responsive
|
start
end
center
|
border_radius |
enum
|
none
xs
sm
md
lg
xl
rounded
|
cursor |
enum
|
auto
default
none
contextMenu
help
pointer
progress
wait
cell
|
dark |
boolean
|
true
false
|
flex |
enum | responsive
|
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none
|
flex_direction |
enum | responsive
|
row
column
rowReverse
columnReverse
|
flex_wrap |
enum | responsive
|
wrap
nowrap
wrapReverse
|
justify_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
line_height |
enum
|
loosest
looser
loose
normal
tight
tighter
tightest
|
margin_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_bottom |
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
|
margin |
array
|
none
xxs
xs
sm
md
lg
xl
|
width |
string
|
|
min_width |
string
|
|
max_width |
string
|
|
gap |
string | responsive
|
|
column_gap |
string | responsive
|
|
row_gap |
string | responsive
|
|
number_spacing |
enum
|
tabular
|
order |
enum | responsive
|
none
first
1
2
3
4
5
6
7
8
9
10
11
12
|
overflow_x |
enum
|
scroll
visible
hidden
auto
|
overflow_y |
enum
|
scroll
visible
hidden
auto
|
overflow |
enum
|
scroll
visible
hidden
auto
|
padding_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_bottom |
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
|
padding |
array
|
none
xxs
xs
sm
md
lg
xl
|
position |
enum
|
relative
absolute
fixed
sticky
static
|
shadow |
enum
|
none
deep
deeper
deepest
|
text_align |
enum | responsive
|
start
end
left
right
center
justify
justifyAll
matchParent
|
truncate |
enum
|
none
1
2
3
4
5
|
vertical_align |
enum | responsive
|
baseline
super
top
middle
bottom
sub
text-top
text-bottom
|
z_index |
enum | responsive
|
1
2
3
4
5
6
7
8
9
10
max
|
top |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
inset |
boolean
|
true
false
|
right |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
bottom |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
left |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
height |
string
|
|
max_height |
string
|
|
min_height |
string
|
|
hover |
object
|
|
group_hover |
boolean
|
true
false
|
| Props | Type | Values | Default |
|---|---|---|---|
options |
record<string, unknown>
|