Circles (Pie chart)
A lightweight JavaScript library that generates circular graphs in SVG.
Official documentation
For more detailed information and examples, see the official documentation: Circles (Pie chart) .
How to use?
To add hs.chart-pie.js
in your page, wrap any block in a parent element with an ID or class and add the same ID or the class in the JS INIT function of the plugin.
Copy-paste the following <script>
near the end of your pages under JS Implementing Plugins to enable it.
Copy-paste the following <script>
near the end of your pages under JS Front to enable it.
Copy-paste the init function under JS Plugins Init., before the closing </body>
tag, to enable it.
Text class
To add secondary and other values within a circle, we positioned the circles with the help of position: absolute;
- and they can be controlled via data-circles-text-class="some-text"
.
For example, data-circles-text-class="content-centered-y"
Size
Fancy larger or smaller circles? Control them with data-circles-radius=""
.
For example, data-circles-radius="30"
Stroke width
The width of the ring. Can be adjusted with data-circles-stroke-width=""
.
For example, data-circles-stroke-width="3"
Stroke linecap
The stroke-linecap
attribute is a presentation attribute defining the shape to be used at the end of open subpaths when they are stroked.
Learn the differences here.
Type
Any unit measurements or icons can be used to demonstrate the stats. Use data-circles-additional-text=""
to show texts or numbers, or use data-circles-type="iconic" data-circles-icon='<span class="far fa-bell"></span>'
for icons.
Additional text
Additional texts are useful to describe/highlight the main values.
Additional texts can be added to the value either after, like this:
or before the value, like this:
data-circles-additional-text-type="prefix"
should be added to put the additional text before the value.
Control the size of the additional text with the use of data-circles-font-size=""
.
And font-weight with data-circles-font-weight=""
.
Secondary text
Add texts or explanations to the circles via data-circles-secondary-*
attributes.
Control the size of the secondary text with the use of data-circles-secondary-font-size=""
.
And font-weight with data-circles-secondary-font-weight=""
.
Set different offset values between additional and secondary texts via data-circles-divider-space=""
.
Methods
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-circles-value=""
.
Attribute | Description |
---|---|
|
Changes block class with text. |
|
Hides the animated value of the graph. |
|
The stroke-linecap attribute is a presentation attribute defining the shape to be used at the end of open subpaths when they are stroked. Available values:
|
|
The stroke-miterlimit attribute is a presentation attribute defining a limit on the ratio of the miter length to the stroke-width used to draw a miter join. When the limit is exceeded, the join is converted from a miter to a bevel. |
|
If the value is prefix , set to prefix, if any other value or absence of value then set to postfix . |
|
Secondary text. |
|
Secondary text color. |
|
Font size of the secondary text. |
|
Font weight of the secondary text. |
|
Distance between main and secondary texts. |
|
If set to true , the graph appears with the animation. |
|
Graph value. |
|
Graph radius. |
|
The maximum value from which the percentage of shares will be considered. |
|
Width of the line graph. |
|
If iconic , then the icon specified in data-circles-icon will be displayed in the center of the graph. |
|
Markup for the icon, which is displayed in the center of the graph, if data-circles-type="" is set to iconic . |
|
Postfix that is added to the value that is displayed in the center of the graph. |
|
Graph background color. |
|
Graph line color. |
|
The animation speed of rendering the graph if data-circles-scroll-animate="" is set to true . |
|
The font size of the graph value that is displayed in the center. |
|
Font-weight of the font value of the graph that is displayed in the center. |
|
The font color of the graph value that is displayed in the center. |