2016-08-18 69 views
1

我有对数y轴的条形图。当我将y轴的min设置为接近0(例如0.1)时,tick之间的间隔看起来相等。但是,当我根据需要将min设置为1000时,图表会更改其行为,并且tick之间的空间不均匀。这里是一个例子https://jsfiddle.net/2vh9h2q3/。这里是代码本身:Higcharts蜱之间不均匀的空间

new Highcharts.Chart({ 
    "chart": { 
     "zoomType": "xy", 
     "renderTo": $('#container')[0], 
     "type": 'bar' 
    }, 
    "title": { 
     "text": null 
    }, 
    "subtitle": { 
     "text": null 
    }, 
    "credits": { 
     "enabled": false 
    }, 
    "exporting": { 
     "enabled": false 
    }, 
    "xAxis": { 
     "categories": ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 
     "title": { 
     "text": null 
     }, 
     "labels": { 
     "align": "left", 
     "x": 10 
     }, 
     "lineWidth": 0, 
     "tickWidth": 0 
    }, 
    "yAxis": { 
    "type": "logarithmic", 
     "min": 1000, 
     "labels": { 
     "formatter": function() { 
      return this.value % 1000 === 0 ? this.value/1000 + "k" : this.value; 
     } 
     }, 
     "title": { 
     "text": null 
     } 
    }, 
    "tooltip": { 
     "useHTML": true, 
     "shadow": false 
    }, 
    "plotOptions": { 
     "bar": { 
     "dataLabels": { 
      "enabled": false 
     } 
     }, 
     "series": { 
     "cursor": "pointer" 

     } 
    }, 
    "series": [{ 
     "showInLegend": false, 
     "data": [4951,1200,0,0,196484,179580,0,0,0,324,87014, 11] 
    }] 
    }); 

我想离开分钟1000并获得刻度之间的间距相等。我试着用滴答选择玩,但它没有工作

回答

1

您可以使用tickPositions或tickPositioner如果你想手动设置刻度线的位置,使它们彼此之间的距离将是相同的:

"yAxis": { 
    "type": "logarithmic", 
    "min": 1000, 
    "labels": { 
    "formatter": function() { 
     return this.value % 1000 === 0 ? this.value/1000 + "k" : this.value; 
    } 
    }, 
    "tickPositions": [3, 4, 5, 6], 
    "title": { 
    "text": null 
    } 
}, 

在tickPositions数组内的这个数字是10的幂。例如,如果你的值等于3,你会在10^3 = 1000的值上看到勾号。

在这里你可以找到一个例子是如何工作的: https://jsfiddle.net/2vh9h2q3/1/

你要记住,你should't使用,如果你想用数轴是小于或等于0的值。