簡體   English   中英

Google圖表-如何從欄中刪除注釋?

[英]Google charts - How to remove annotation from the bars?

我真的不知道,該怎么稱呼? 注解或圖例? 我認為兩者都與此不同。 看一下圖片

條狀圖

我發現並嘗試了各種方法來刪除注釋/傳說

 legend: {position: 'none'}

但是,沒有成功。 請幫我解決。 謝謝。

在Google圖表中,這些是注釋,並被添加到圖表中,
通過使用'annotation' 列角色將列添加到數據表

要刪除,請從數據表中刪除列。
請參閱以下代碼段...

之前...

var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn('number', 'y0');
data.addColumn({type: 'string', role: 'annotation'});  // <-- remove
data.addColumn('number', 'y1');
data.addColumn({type: 'string', role: 'annotation'});  // <-- remove
data.addColumn('number', 'y2');
data.addColumn({type: 'string', role: 'annotation'});  // <-- remove
data.addRow(['a', 1, '1', 1, '1', 1, '1']);  // <-- remove string values for above columns

后...

var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn('number', 'y0');
data.addColumn('number', 'y1');
data.addColumn('number', 'y2');
data.addRow(['a', 1, 1, 1]);

也可以使用DataView的計算列添加注釋。
請參閱以下代碼段...

之前...

var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
                 { calc: "stringify",    // <-- remove calculated column
                   sourceColumn: 1,
                   type: "string",
                   role: "annotation" },
                 2]);

后...

var view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM