FusionCharts API-Methods: chartType
Created using FusionCharts Suite XT - www.fusioncharts.com
by FusionCharts
HTML
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<!-- This sample shows the usage of the chartType() method. -->
<div id="indicatorDiv">Method Name: <strong>chartType()</strong>
<p>Gets or sets the chart type of a FusionCharts instance. To <strong>get</strong> the current chart type, call this function without any parameters. To <strong>set</strong> a new chart type, pass the chart type as the first parameter to this function. When a new chart type is set, the chart is automatically re-rendered and the <strong>chartTypeChanged</strong> event is triggered.</p>
<p>In this sample, a column 2D chart is originally rendered. From the drop-down shown below, select a chart type to re-render this chart in a different type.</p>
<select id="type" class="mb-20">
<option value="bar2d">Bar 2D Chart</option>
<option value="line">Line 2D Chart</option>
<option value="column2d">Column 2D Chart</option>
</select>
<div id="message"></div>
<div id="chart-container1">FusionCharts will render here</div>
</div>
CSS
body {
padding: 5px;
margin: 0 auto;
}
strong{
font-weight: bold;
}
.text-center {
text-align: center;
}
.mb-20 {
margin-bottom: 20px;
}
p {
margin: 10px auto;
}
#indicatorDiv {
width: 500px;
font-family:'Arial', 'Helvetica';
font-size: 13px;
}
#type {
height: 25px;
font-size: 13px;
}
#message {
width: 500px;
font-family:'Arial', 'Helvetica';
font-size: 13px;
}
JavaScript
FusionCharts.ready(function () {
var revenueChart = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container1',
width: '500',
height: '250',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Monthly revenue for last year",
"subCaption": "Harry's SuperMart",
"xAxisName": "Month",
"yAxisName": "Revenue (In USD)",
"numberPrefix": "$",
"paletteColors": "#0075c2",
"bgColor": "#ffffff",
"borderAlpha": "20",
"canvasBorderAlpha": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"placevaluesInside": "1",
"rotatevalues": "1",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineIsDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"captionFontSize": "13",
"subcaptionFontSize": "12"
},
"data": [{
"label": "Jan",
"value": "420000"
}, {
"label": "Feb",
"value": "810000"
}, {
"label": "Mar",
"value": "720000"
}, {
"label": "Apr",
"value": "550000"
}, {
"label": "May",
"value": "910000"
}, {
"label": "Jun",
"value": "510000"
}, {
"label": "Jul",
"value": "680000"
}, {
"label": "Aug",
...