圆形词云(旋转)TagCanvas

本文介绍了一种利用jQuery插件制作的词云插件,展示了如何将古典诗词中的'朝歌夜弦'与'倾城倾国'转化为动态的视觉元素,通过'客流标签词云'形式再现历史风采。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

昔有朝歌夜弦之高楼,上有倾城倾国之舞袖。

在这里插入图片描述

首先咱们需要一个插件这个插件是jQuery的插件

官方文档英文的[Facepalm]

css 就不往上贴了 太多了 懒得找
代码是这样的 HTML

div class="cy data-flow">
            <div class="data-flow-content" data-title="客流标签词云">
              <!-- 客流标签词云 -->
              <div id="canvas-ifrshb" class="Rotation">
                <canvas id="canvas-yrieay">
                  <p>Anything in here will be replaced on browsers that support the canvas element</p>
                </canvas>
              </div>
              <div style="display: none" class="data-flow-label" id="tags">
                <ul></ul>
              </div>
            </div>
          </div>

JS

const update = function () {
  if (!$('#canvas-yrieay').tagcanvas({
    textFont: 'Impact,"Arial Black",sans-serif',
    textColour: '#fff',
    outlineColour: '#0743EC',
    reverse: true,
    textHeight: 16,
    shape: "sphere",
    depth: 0.8,
    decel: 0.99,
    padding: 0,
    wheelZoom: true,
    dragControl: false,
    fadeIn: 0,
    freezeActive: false,
    outlineMethod: "outline",
    outlineOffset: "5",
    outlineRadius: "0",
    outlineThickness: "2",
    maxSpeed: 0.05,
    initial: [0.1, -0.2], // 配置旋转速度
  }, 'tags')) {
    $('#canvas-yrieay').hide();
  }
};
const getHtml = function (result: Array) {
  $('#canvas-yrieay').attr('width', $('#canvas-ifrshb').width());
  $('#canvas-yrieay').attr('height', $('#canvas-ifrshb').height() - 10);
  const $label = $('.data-flow-label ul', '#app');
  const html = getLabels(result);
  $label.html('');
  $label.prepend(html);
  update();
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值