我在highcharts中有一个wordcloud,在这里我需要动态更改小于5的权重以正确显示每个单词。在这里,我的最大权重为100,其他权重为5,2,1,因此权重较少无法正确显示。 这是下面的代码。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/wordcloud.js"></script>
<div id="container"></div>
var data = [{
name: 'Lorem',
weight: 100
}, {
name: 'Ipsum',
weight: 2
}, {
name: 'Dolor',
weight: 1
}];
Highcharts.chart('container', {
series: [{
type: 'wordcloud',
data: data,
name: 'Occurrences'
}],
title: {
text: 'Wordcloud of Lorem Ipsum'
}
});
答案 0 :(得分:0)
您可以预处理数据并在某些点上增加weight
值:
data.forEach(function(el) {
if (el.weight < 5) {
el.weight *= 10;
}
});