UNPKG

oecd-simple-charts

Version:

D3 charting library for creating pearl charts, stacked bar charts and box plots

927 lines (321 loc) 15.2 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>PearlChart - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BoxPlot.html">BoxPlot</a><ul class='methods'><li data-type='method'><a href="BoxPlot.html#update">update</a></li></ul></li><li><a href="PearlChart.html">PearlChart</a><ul class='methods'><li data-type='method'><a href="PearlChart.html#update">update</a></li></ul></li><li><a href="StackedChart.html">StackedChart</a><ul class='methods'><li data-type='method'><a href="StackedChart.html#update">update</a></li></ul></li></ul> </nav> <div id="main"> <h1 class="page-title">PearlChart</h1> <section> <header> <h2> PearlChart </h2> <div class="class-description"><p>A pearl chart component.</p></div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="PearlChart"><span class="type-signature"></span>new PearlChart<span class="signature">(options)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="PearlChart.js.html">PearlChart.js</a>, <a href="PearlChart.js.html#line67">line 67</a> </li></ul></dd> </dl> <h5>Example</h5> <pre class="prettyprint"><code>var callbackFunc = function(data) { console.log(data); } var PearlChartExample = new OECDCharts.PearlChart({ container: '#PearlChartExample', extent: [300, 600], title: 'Pearl Chart', renderInfoButton: true, showTicks: true, showLabels: false, colorLabels: true, callback: callbackFunc, data: [ { value: 410, color: '#900c3f' }, { value: 520, color: '#189aa8' } ], labelFormat: function(val) { return Math.round(val) + '$'; } });</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>The options object for the pearl chart.</p> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>container</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>The DOM element to use as container</p></td> </tr> <tr> <td class="name"><code>title</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>The title to display</p></td> </tr> <tr> <td class="name"><code>renderInfoButton</code></td> <td class="type"> <span class="param-type">bool</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last"><p>The info-Icon for the tooltip, renders after the title</p></td> </tr> <tr> <td class="name"><code>fontSize</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>14</code> </td> <td class="description last"><p>The font-size for the labels in px</p></td> </tr> <tr> <td class="name"><code>radius</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>10</code> </td> <td class="description last"><p>The radius for the pearl in px</p></td> </tr> <tr> <td class="name"><code>ticks</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>4</code> </td> <td class="description last"><p>The number of ticks displayed under the pearl chart, will only be used if tickValues is not set</p></td> </tr> <tr> <td class="name"><code>tickValues</code></td> <td class="type"> <span class="param-type">array</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>An array of numbers that are displayed as ticks</p></td> </tr> <tr> <td class="name"><code>showTicks</code></td> <td class="type"> <span class="param-type">bool</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last"><p>Hide or show ticks</p></td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>A function that is called on circle click</p></td> </tr> <tr> <td class="name"><code>labelFormat</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>val => Math.round(val * 10) / 10</code> </td> <td class="description last"><p>A function for formatting circle labels</p></td> </tr> <tr> <td class="name"><code>showLabels</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last"><p>Hide or show circle labels</p></td> </tr> <tr> <td class="name"><code>colorLabels</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last"><p>Fill labels in circle color or black</p></td> </tr> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">array</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>The data as array. i.e.:</p> <pre class="prettyprint source"><code>[ { value: 410, color: '#900c3f' }, { value: 520, color: '#189aa8' } ]</code></pre></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(data)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="PearlChart.js.html">PearlChart.js</a>, <a href="PearlChart.js.html#line149">line 149</a> </li></ul></dd> </dl> <h5>Example</h5> <pre class="prettyprint"><code>PearlChartExample.update([ { value: 490, color: '#900c3f' }, { value: 820, color: '#189aa8' } ]);</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">array</span> </td> <td class="description last"><p>an array containing objects with the new data</p></td> </tr> </tbody> </table> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>