[英]Google Charts Category Filter - Hide html tags or convert the elements to links
Is anybody has an idea how the html tags can be hidden or can be converted to html links in the category filter ? 是否有人知道如何在类别过滤器中隐藏html标签或将其转换为html链接? I am having the following issue:
我遇到以下问题:
In the chart table for one of the columns I am providing html links. 在图表表的其中一列中,我提供了html链接。 I am setting the property
allowHtml:true
in the ChartWrapper()
. 我在
ChartWrapper()
设置属性allowHtml:true
。 In the table the links are displaying properly. 在表格中,链接显示正确。 When I put filtering on that column the dropdown is getting the whole value of the column including the html.
当我对该列进行过滤时,下拉列表将获取包括html在内的整个列的值。 Unfortunately there isn't a property allowHtml for the
ControlWrapper()
. 不幸的是
ControlWrapper()
没有属性allowHtml。 Here is how the filter is looking. 这是过滤器的外观。
to remove the html from the CategoryFilter
, 从
CategoryFilter
删除html,
for each cell in the data table column, 对于数据表列中的每个单元格,
use the value property ( v:
) for the value to be displayed in the filter, 将value属性(
v:
用于要在过滤器中显示的值,
and the formatted value property ( f:
) for the link 以及链接的格式化值属性(
f:
:)
see following working snippet... 请参阅以下工作片段...
google.charts.load('current', { callback: function () { var data = new google.visualization.DataTable({ cols: [ {label: 'Link', type: 'string'} ], rows: [ {c:[{v: 'Test 1', f: '<a href="https://www.google.com/">Test 1</a>'}]}, {c:[{v: 'Test 2', f: '<a href="https://www.google.com/">Test 2</a>'}]}, {c:[{v: 'Test 3', f: '<a href="https://www.google.com/">Test 3</a>'}]}, {c:[{v: 'Test 4', f: '<a href="https://www.google.com/">Test 4</a>'}]}, {c:[{v: 'Test 5', f: '<a href="https://www.google.com/">Test 5</a>'}]}, {c:[{v: 'Test 6', f: '<a href="https://www.google.com/">Test 6</a>'}]} ] }); var dashboard = new google.visualization.Dashboard( document.getElementById('dashboard') ); var control = new google.visualization.ControlWrapper({ controlType: 'CategoryFilter', containerId: 'control', options: { filterColumnIndex: 0, ui: { allowTyping: false, } } }); var chart = new google.visualization.ChartWrapper({ chartType: 'Table', containerId: 'table', options: { allowHtml: true } }); dashboard.bind(control, chart); dashboard.draw(data); }, packages: ['controls', 'table'] });
<script src="https://www.gstatic.com/charts/loader.js"></script> <div id="dashboard"> <div id="control"></div> <div id="table"></div> </div>
note: not sure how to get the actual link to display in the filter, 注意:不确定如何获取实际链接以显示在过滤器中,
but that could interfere with actually selecting a value anyway 但这可能会干扰实际选择值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.