在单词树可视化中使用大量字符串
Using large set of strings in word tree visualization
我无法复制并粘贴我的文件中的所有字符串和运行使用此示例的代码
https://developers.google.com/chart/interactive/docs/gallery/wordtree
https://jsfiddle.net/api/post/library/pure/
我修改了 html 和 javascript 代码,并用我文件中的一小组字符串替换了短语,然后一切正常。现在我想对我的完整文件做同样的事情,但是要复制和粘贴的字符串太多了。我如何使用 javascript 导入我的大型数据集,以及如何使用“['some text here']”使每一行的格式相同,或者 javascript 在上传文件时插入括号?
HTML 文件:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {packages:['wordtree']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(
[ ['Phrases'],
['return refund not received'],
['hello, every time i try to print the invoice, nothing loads. i have tried different browsers and devices. can i get it emailed to me?'],
['how long for delivery and do i need a prescription'],
['i recently requested replacement lenses for some that were defective and received the wrong prescription'],
['my order is pending verification of prescription. however, my prescription hasn’t changed and i ordered last month without any delays.'],
]
);
var options = {
wordtree: {
format: 'implicit',
//alt is 'suffix', 'prefix'
type: 'double',
word: 'prescription'
}
};
var chart = new google.visualization.WordTree(document.getElementById('wordtree_basic'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="wordtree_basic" style="width: 1800px; height: 1000px;"></div>
</body>
</html>
JavaScript 文件:
google.charts.load('current', {packages:['wordtree']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(
[ ['Phrases'],
['return refund not received'],
['hello, every time i try to print the invoice, nothing loads. i have tried different browsers and devices. can i get it emailed to me?'],
['how long for delivery and do i need a prescription'],
['i recently requested replacement lenses for some that were defective and received the wrong prescription'],
['my order is pending verification of prescription. however, my prescription hasn’t changed and i ordered last month without any delays.'],
]
);
var options = {
wordtree: {
format: 'implicit',
//alt is 'suffix', 'prefix'
type: 'double',
word: 'prescription'
}
};
var chart = new google.visualization.WordTree(document.getElementById('wordtree_basic'));
chart.draw(data, options);
}
我希望能够从我的桌面(或其他位置)上传文件(csv 格式),而不是复制和粘贴我的开放式反馈的一小部分。谢谢
您可以使用 Google sheet.
片段:
function drawVisualization() {
var wrapper = new google.visualization.ChartWrapper({
chartType: 'WordTree',
dataSourceUrl: 'http://spreadsheets.google.com/tq?key=pCQbetd-CptGXxxQIG7V',
query: 'SELECT A',
containerId: 'wordtree_basic'
});
}
阅读:
我无法复制并粘贴我的文件中的所有字符串和运行使用此示例的代码
https://developers.google.com/chart/interactive/docs/gallery/wordtree
https://jsfiddle.net/api/post/library/pure/
我修改了 html 和 javascript 代码,并用我文件中的一小组字符串替换了短语,然后一切正常。现在我想对我的完整文件做同样的事情,但是要复制和粘贴的字符串太多了。我如何使用 javascript 导入我的大型数据集,以及如何使用“['some text here']”使每一行的格式相同,或者 javascript 在上传文件时插入括号?
HTML 文件:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {packages:['wordtree']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(
[ ['Phrases'],
['return refund not received'],
['hello, every time i try to print the invoice, nothing loads. i have tried different browsers and devices. can i get it emailed to me?'],
['how long for delivery and do i need a prescription'],
['i recently requested replacement lenses for some that were defective and received the wrong prescription'],
['my order is pending verification of prescription. however, my prescription hasn’t changed and i ordered last month without any delays.'],
]
);
var options = {
wordtree: {
format: 'implicit',
//alt is 'suffix', 'prefix'
type: 'double',
word: 'prescription'
}
};
var chart = new google.visualization.WordTree(document.getElementById('wordtree_basic'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="wordtree_basic" style="width: 1800px; height: 1000px;"></div>
</body>
</html>
JavaScript 文件:
google.charts.load('current', {packages:['wordtree']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(
[ ['Phrases'],
['return refund not received'],
['hello, every time i try to print the invoice, nothing loads. i have tried different browsers and devices. can i get it emailed to me?'],
['how long for delivery and do i need a prescription'],
['i recently requested replacement lenses for some that were defective and received the wrong prescription'],
['my order is pending verification of prescription. however, my prescription hasn’t changed and i ordered last month without any delays.'],
]
);
var options = {
wordtree: {
format: 'implicit',
//alt is 'suffix', 'prefix'
type: 'double',
word: 'prescription'
}
};
var chart = new google.visualization.WordTree(document.getElementById('wordtree_basic'));
chart.draw(data, options);
}
我希望能够从我的桌面(或其他位置)上传文件(csv 格式),而不是复制和粘贴我的开放式反馈的一小部分。谢谢
您可以使用 Google sheet.
片段:
function drawVisualization() {
var wrapper = new google.visualization.ChartWrapper({
chartType: 'WordTree',
dataSourceUrl: 'http://spreadsheets.google.com/tq?key=pCQbetd-CptGXxxQIG7V',
query: 'SELECT A',
containerId: 'wordtree_basic'
});
}