FusionCharts - Configuring point value visibility in Sparkline chart
Created using FusionCharts Suite XT - www.fusioncharts.com
by FusionCharts
HTML
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<!-- Configure open, close, high/low point value visibility in SparkLine chart using attributes:
# showOpenValue - Whether to show the opening value beside the chart
# showCloseValue - Whether to show the closing value beside the chart
# showHighLowValue - Whether to show the high and low value beside the chart
-->
<div id="chart-container">FusionCharts will render here</div>
<div id="checkbox-container">
<input type="checkbox" id="open">Show Open Value ?</input>
<input type="checkbox" id="close">Show Close Value ?</input>
<input type="checkbox" id="highLow">Show High/Low Values ?</input>
</div>
CSS
#checkbox-container {
margin-top: 10px;
width: 400px;
}
body {
font-family: 'Helvetica Neue', Arial;
font-size: 11px;
font-weight: normal;
}
JavaScript
FusionCharts.ready(function() {
var openCB = document.getElementById('open'),
closeCB = document.getElementById('close'),
highLowCB = document.getElementById('highLow'),
//Function to show/hide anchors
showAnchor = function(evt) {
//Storing the attributes names to get the names dynamically
var attrbObj = {
open: 'showOpenValue',
close: 'showCloseValue',
highLow: 'showHighLowValue'
},
attrbName = attrbObj[evt.target.id];
(evt.target.checked) ? stockPriceChart.setChartAttribute(attrbName, 1): stockPriceChart.setChartAttribute(attrbName, 0);
},
stockPriceChart = new FusionCharts({
type: 'sparkline',
renderAt: 'chart-container',
width: '450',
height: '70',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fusion",
"caption": "Stock Price",
"subcaption": "Last month",
"numberPrefix": "$",
"chartBottomMargin": "30",
"showOpenValue": "0",
"showCloseValue": "0",
"showHighLowValue": "0"
},
"dataset": [{
"data": [{
"value": "38.42"
},
{
"value": "41.43"
},
{
"value": "34.78"
},
{
"value": "40.67"
},
{
"value": "44.12"
},
{
"value": "38.45"
},
{
"value": "40.71"
},
{
"value": "49.90"
},
{
"value": "40.12"
},
{
"value": "34.91"
},
{
"value": "42.02"
},
{
"value": "35.21"
},
{
"value": "43.31"
},
{
"value": "40.21"
},
...