[英]Is it possible to plot points on a line graph using two separate arrays? (highcharts)
[英]very simple highcharts column graph with two arrays
我正在嘗試制作一個簡單的 highcharts 柱形圖。 highcharts 網站上的文檔比我需要的更復雜,我只是不知道如何為 y 軸使用簡單的數組。 到目前為止,這是我的代碼。
var species=[Acer rubrum,Tsuga canadensis,Pinus strobus];
var counts=[17746,10384,9986];
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Top 10 Species'
},
subtitle: {
text: 'by basal area'
},
xAxis: {
categories: species,
title: {
text: 'Species'
}
},
yAxis: {
min: 0
},
series: [{ name: null, data: topSpecies }]
});
}
這給了我沿 x 軸列出的正確物種,但我想要沿 y 的計數,目前它是空白的並且沒有列。 任何幫助表示贊賞!
謝謝你。
您對系列數據使用了錯誤的變量。 使用counts
而不是topSpecies
。
var species = ['Acer rubrum', 'Tsuga canadensis', 'Pinus strobus'];
var counts = [17746, 10384, 9986];
Highcharts.chart('container', {
...,
series: [{
name: null,
data: counts
}]
});
現場演示: http://jsfiddle.net/BlackLabel/yfesv93x/
API 參考: https://api.highcharts.com/highcharts/series.column.data
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.