如何解决Amcharts v3:关于折线图/序列图的问题
请检入Codepen(根据官方示例进行一些修改)。
我的问题是:当鼠标无间隔移动时,我是否可以将气球设置为始终指向上一个点。
例如:在codepen中,如果鼠标在2000到2001之间移动,我希望气球指向2000。
/**
* amCharts plugin
* Before the chart is initialized,this plugin will sort the `graphs` array
* by their `index` value
*/
AmCharts.addInitHandler(function(chart) {
// Reorder chart graph's based on their "index" value
chart.graphs.sort(function(a,b) {
if (a.index == b.index) {
return 0;
}
return a.index < b.index ? -1 : 1;
});
},["serial"]);
/**
* Make the chart
*/
var chart = AmCharts.makeChart("chartdiv",{
"type": "serial","legend": {
"align": "center","equalWidths": false,"periodValueText": "total: [[value.sum]]","valueAlign": "left","valueText": "[[value]] ([[percents]]%)","valueWidth": 100
},"dataProvider": [
{
"year": "1994","cars": 1587,"motorcycles": 650,},{
"year": "1995","cars": 1567,{
"year": "1996","cars": 1617,"motorcycles": 691,{
"year": "1997","cars": 1630,{
"year": "1998","cars": 1660,"motorcycles": 699,{
"year": "1999","cars": 1683,{
"year": "2000","cars": 1691,"motorcycles": 737,{
"year": "2001","cars": 1298,{
"year": "2002","cars": 1275,"motorcycles": 664,{
"year": "2003","cars": 1246,{
"year": "2004","cars": 1218,"motorcycles": 637,{
"year": "2005","cars": 1213,{
"year": "2006","cars": 1199,"motorcycles": 621,{
"year": "2007","cars": 1110,{
"year": "2008","cars": 1165,"motorcycles": 232,{
"year": "2009","cars": 1145,{
"year": "2010","cars": 1163,"motorcycles": 201,{
"year": "2011","cars": 1180,{
"year": "2012","cars": 1159,"motorcycles": 277,}
],"valueAxes": [{
"stackType": "regular","position": "left","title": "percent"
}],"graphs": [{
"title": "Cars","valueField": "cars","index": 2
},{
"title": "Motorcycles","valueField": "motorcycles","index": 3
}],"plotAreaBorderAlpha": 0,"marginLeft": 0,"marginBottom": 0,"chartCursor": {
"cursorAlpha": 0,"zoomable": false
},"categoryField": "year","categoryAxis": {
"startOnAxis": true,"axisColor": "#DADADA","gridAlpha": 0.07
},chartCursor: {
cursorPosition: 'mouse',});
#chartdiv {
width: 100%;
height: 500px;
}
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。