Dynamically toggle between logarithmic and regular scale
HTML
<script type="text/javascript" src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="http://www.amcharts.com/lib/3/serial.js"></script>
<script type="text/javascript" src="http://www.amcharts.com/lib/3/themes/none.js"></script>
<div id="chartdiv"></div>
<input type="button" value="toggle logarithmic" onclick="toggle();" id="button" />
CSS
body {
font-family: Verdana;
font-size: 12px;
padding: 10px;
}
#chartdiv {
width : 100%;
height : 500px;
}
#button {
padding: 10px;
font-size: 15px;
position: absolute;
top: 60px;
right: 30px;
}
JavaScript
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "none",
"pathToImages": "http://www.amcharts.com/lib/3/images/",
"dataProvider": [{
"date": "2012-03-01",
"price": 20
}, {
"date": "2012-03-02",
"price": 75
}, {
"date": "2012-03-03",
"price": 15
}, {
"date": "2012-03-04",
"price": 75
}, {
"date": "2012-03-05",
"price": 158
}, {
"date": "2012-03-06",
"price": 57
}, {
"date": "2012-03-07",
"price": 107
}, {
"date": "2012-03-08",
"price": 89
}, {
"date": "2012-03-09",
"price": 75
}, {
"date": "2012-03-10",
"price": 132
}, {
"date": "2012-03-11",
"price": 158
}, {
"date": "2012-03-12",
"price": 56
}, {
"date": "2012-03-13",
"price": 169
}, {
"date": "2012-03-14",
"price": 24
}, {
"date": "2012-03-15",
"price": 147
}],
"valueAxes": [{
"logarithmic": true,
"dashLength": 1,
"guides": [{
"dashLength": 6,
"inside": true,
"label": "average",
"lineAlpha": 1,
"value": 90.4
}],
"position": "left"
}],
"graphs": [{
"bullet": "round",
"id": "g1",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 7,
"lineThickness": 2,
"title": "Price",
"type": "smoothedLine",
"useLineColorForBulletBorder": true,
"valueField": "price"
}],
"chartScrollbar": {},
"chartCursor": {
"cursorPosition": "mouse"
},
"categoryAxis": {
"logarithmic" : true;
}
});
function toggle() {
chart.categoryAxes[0].logarithmic = chart.categoryAxes[0].logarithmic ? false : true;
chart.validateNow();
}