FusionCharts - Add trend lines to a chart
Created using FusionCharts Suite XT - www.fusioncharts.com
by Vishalika
HTML
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!--
Trend lines let you highlight a pre-set that can act as a benchmark or comparison indicator for the data points. You use the trendlines element to add trend lines to the chart, and can add any number of trend lines.
Element:
1. Trendline
Attributes:
1. startvalue
2. color
3. displayValue (etc)
-->
<div id="chart-container">FusionCharts will render here</div>
JavaScript
FusionCharts.ready(function () {
var salesChart = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
id: 'myChart',
width: '450',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Quarterly Sales Summary",
"subcaption": "Last year",
"xaxisname": "Quarter",
"yaxisname": "Amount (In USD)",
"yaxismaxvalue":"250000",
"numberprefix": "$",
"theme": "fint"
},
"data": [
{
"label": "Q1",
"value": "195000"
},
{
"label": "Q2",
"value": "155000"
},
{
"label": "Q3",
"value": "178000"
},
{
"label": "Q4",
"value": "192000"
}
],
"trendlines": [
{
"line": [
{
"isTrendZone": "1",
"valueOnRight":"1",
"startvalue": "175000",
"endvalue": "225000",
"color": "#1aaf5d",
"displayvalue": "Target - $175K"
}
]
}
]
}
}).render();
});