2016-09-21 82 views
0

我使用此post中使用此jsfiddleAmCharts股票圖表:刪除比較選擇框

一切正常,但我找不到方法來刪除「比較:」標籤下方的選擇框,如圖中紅框所示。

enter image description here

有沒有一種方法可以隱藏或關閉呢?

我嘗試以下dataSetSelector設置,但這只是去掉了「比較到」文本,而不是選擇下面的框:

dataSetSelector: { 
    selectText :"", 
    compareText: "", 
    comboBoxSelectText : "", 
    position: "top" 
} 

回答

1

可以刪除比較選擇使用CSS:

/* hide the compare box */ 
.amcharts-compare-div { 
    display: none; 
} 

/* 
    hide all <br> tags after the dropdown, 
    if dataSetSelector position is set to top or bottom, 
    hide the select due to different markup 
*/ 
.amcharts-data-set-select ~ br, .amcharts-data-set-select ~ select { 
    display: none; 
} 

/* add a margin-bottom to space out the dropdown from the from/to text boxes */ 
.amcharts-data-set-select { 
    margin-bottom: 1em; 
} 

您仍然需要將compareText設置爲dataSetSelector中的空字符串以刪除Compare to:字符串。

演示:http://codepen.io/team/amcharts/pen/e6cb53e53222eba93e80cf7e0be98987

你可以找到通過AmCharts這裏設置類名稱的信息:http://www.amcharts.com/tutorials/css-class-names/

更新同時還處理當dataSetSelector的位置被設置爲「頂」或「底」,由於不同標記。

+0

非常感謝!問題是我已經從左到頂改變了:dataSetSelector:{position:「top」}並且不適合這個位置。爲什麼? – ranell

+1

有趣。看起來像圖表爲位置頂部和底部生成不同的標記。我更新了我的答案演示和CSS。您需要將'.amcharts-data-set-select〜select'添加到隱藏
標籤的規則中。 – xorspark

+0

完美!非常感謝,它的工作:)我有更多的問題,我道歉。在更改圖表時是否可以關聯其他操作? (例如隱藏div)。我試過類似的東西,但不起作用:$(function(){(。。amcharts-data-set-select「)。change(function(){ \t $(」#div「)。 hide(200); }); }); 再次感謝。 – ranell