2017-07-09 78 views
0

我使用python-nvd3在python中創建了一個多欄圖表。python-nvd3 missing xAxis ticks

問題是在圖表上只顯示每隔一秒的X軸勾號/標籤。

我生成的是python中的圖表,然後將它傳遞給燒瓶模板。

該問題在另一個SO帖子中也有描述,但解決方案針對的是Angular,並沒有指出我可以在創建它之前將python中的屬性傳遞給圖表的方式。


StackOverflow solution 1 here

StackOverflow solution 2 here


解決辦法建議設置屬性.reduceXTicks(true)但我的問題是,我看不到的方式來設置此蟒自定義屬性。

這是圖表的樣子。

enter image description here

我這是怎麼生成圖表,也是我的X和Y軸數據如下:

fchart = multiBarChart(name='f_multibarchart', width=1000, height=400, x_axis_format=None, color_category="category10") 

xdata ['510', '125', '630', '625', '650', '1000', '805', '515', '610', '800'] 
ydata1 [0, 0, 0, 0, 1, 15, 0, 0, 0, 0] 
ydata2 [1, 17, 23, 1, 29, 0, 0, 2, 0, 13] 

fchart.add_serie(name="Full", y=ydata1, x=xdata) 
fchart.add_serie(name="Low", y=ydata2, x=xdata) 

任何幫助,將不勝感激

回答

2

問題解決了!

設置reduceXTicks(false)沒有工作對我來說。

我發現缺失X tick的不透明度設置爲0,所以我所做的就是使用add_chart_extras()函數將不透明度推到1的所有刻度。

fchart = multiBarChart(name='f_multibarchart', width=1000, height=400, x_axis_format=None, color_category="category10") 
extras = "d3.selectAll('#f_multibarchart text').style('opacity', '1');" 
fchart.add_chart_extras(extras) 

enter image description here