0
我在我的散點圖表中顯示數據時出現問題。我試圖將速度作爲x軸並建立y軸。如果我從f.series中刪除變量並放置數據=> [[3,120]],它會起作用,但變量會給我一個空白圖。LazyHighcharts散點圖問題
@planter_speed = PlanterSpeed.find(params[:id])
@data = CSV.open(@planter_speed.file.path, :headers => false,
:encoding => 'ISO-8859-1')
speed = []
established = []
@data.each do |row|
speed << row[0]
established << row[1].to_i
end
@graph = LazyHighCharts::HighChart.new('graph') do |f|
f.chart(:height => '300')
f.xAxis(:title => {:text => 'Speed km/hr',
:margin => 20, style: { color: '#333'}}, :min => 0, :max => 16)
f.yAxis [min: 0, max: 120]
f.series(:type => 'scatter', :name =>
'% Established over planted',
data: [[speed, established]], :color => '#00463f')
f.plotOptions({line: {enableMouseTracking: false}})
f.legend({:align => 'center', :verticalAlign=> 'top',
:y => 0, :borderWidth => 0, style: {color: "#333"}})
end
十分感謝Steakchaser。我還必須將[0] .to_i排列以顯示速度結果。 – DollarChills