首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >你有什么好主意(设置)来显示高图表中有很多字符的标题吗?

你有什么好主意(设置)来显示高图表中有很多字符的标题吗?
EN

Stack Overflow用户
提问于 2022-01-11 08:54:08
回答 1查看 42关注 0票数 0

当这一节的标题中有太多的字符时,很难看到。因此,我想限制始终可见的部分中的字符数。另外,当鼠标悬停时,我希望能够在弹出窗口中看到标题中的所有字母。

这是我的小提琴

代码语言:javascript
复制
<script src="https://code.highcharts.com/7.1.1/highcharts.js"></script>
<script src="https://code.highcharts.com/7.1.1/modules/venn.js"></script>
<script src="https://code.highcharts.com/7.1.1/modules/exporting.js"></script>
<script src="https://code.highcharts.com/7.1.1/modules/accessibility.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
</figure>

Highcharts.chart('container', {
  accessibility: {
    point: {
      descriptionFormatter: function(point) {
        var intersection = point.sets.join(', '),
          name = point.name,
          ix = point.index + 1,
          val = point.value;
        return ix + '. Intersection: ' + intersection + '. ' +
          (point.sets.length > 1 ? name + '. ' : '') + 'Value ' + val + '.';
      }
    }
  },
  tooltip: {
    pointFormat: 'data: {point.name}',
  },
  series: [{
    type: 'venn',
    name: 'ユーザー名',
    data: [{
      sets: ['Good'],
      value: 2,
      name: 'When there are too many characters in the title of this section, it is very difficult to see. Therefore, I would like to limit the number of characters in the part that is always visible. Also, I would like to be able to see all the letters of the title in the popup when the mouse is hovered.',
      overflow: 'allow',
      crop: false
    }, {
      sets: ['Cheap'],
      value: 2
    }, {
      sets: ['Good', 'Cheap'],
      value: 1,
    }]
  }],
  title: {
    text: 'The Unattainable Triangle'
  }
});

然而,https://www.highcharts.com/docs/chart-design-and-style/style-by-css#what-can-be-styled不能控制像标题或图例这样的元素的布局和位置。

我考虑过用CSS设计它的样式,但有人告诉我,不能用CSS控制title属性。

还有别的办法吗?

我想做什么

  • 当名字有太多字符时,缩短它的名字。
  • 悬停显示全文
EN

回答 1

Stack Overflow用户

发布于 2022-01-11 13:02:06

对于dataLabel设置,使用dataLabels.style.textOverflow,可以在dataLabels.format中添加dataLabels.format标记,如果添加类,则可以更改dataLabels.format中的行为。

代码语言:javascript
复制
  plotOptions: {
    venn: {
      dataLabels: {
        useHTML: true,
        format: '<p class="truncate"><b>{point.name}</b></p>',
        style: {
          textOverflow: 'ellipsis'
        }
      }
    }
  },

https://api.highcharts.com/highcharts/plotOptions.venn.dataLabels

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70663975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档