html 词云
时间: 2023-07-01 09:12:13 浏览: 56
好的,以下是使用 WordCloud.js 库生成词云的 HTML 代码示例,可以供您参考:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>词云示例</title>
<script src="https://cdn.bootcss.com/d3-cloud/1.2.5/d3.layout.cloud.min.js"></script>
<script src="https://cdn.bootcss.com/wordcloud2.js/1.0.6/wordcloud2.min.js"></script>
<style>
#wordcloud {
width: 600px;
height: 400px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="wordcloud"></div>
<script>
var word_list = [
{ text: 'HTML', weight: 10 },
{ text: 'CSS', weight: 8 },
{ text: 'JavaScript', weight: 12 },
{ text: 'Web', weight: 9 },
{ text: 'API', weight: 7 },
{ text: 'Ajax', weight: 5 },
{ text: 'Bootstrap', weight: 6 },
{ text: 'jQuery', weight: 8 },
{ text: 'React', weight: 11 },
{ text: 'Vue', weight: 10 }
];
WordCloud(document.getElementById('wordcloud'), {
list: word_list,
weightFactor: 40,
minSize: 10,
color: '#36a',
backgroundColor: '#fff',
shape: 'square',
fontFamily: 'Impact',
rotateRatio: 0.5,
rotationSteps: 2
});
</script>
</body>
</html>
```
这段代码会生成一个简单的词云图形,展示了一些常见的前端技术词汇。您可以根据实际需求修改数据、样式和配置等。