RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1420741
Accepted
Pashok
Pashok
Asked:2022-08-16 13:37:08 +0000 UTC2022-08-16 13:37:08 +0000 UTC 2022-08-16 13:37:08 +0000 UTC

在 highcharts 菜单中选择一个项目后如何更改其名称?

  • 772

有一些图形数据,在选择项目时有必要制作板的外观。但是标准函数不支持html格式的表格标题,虽然图表标题正常支持。我通过在菜单中添加一个新按钮来做到这一点menuItemDefinitions,exporting但是如何在选择后覆盖其文本?与标准输出一样,它是必要的。改为View data table,Hide data table反之亦然。我们现在拥有的代码和我们想要的照片如下所示:在此处输入图像描述

var html = '<div style="display: inline-block"></div>';
html += '<div style="display: inline-block; margin-left: 20px; cursor: pointer;" class="description-title" id="">';
html += '<img style="width: 20px;" src="https://img.icons8.com/ios/500/info--v1.png" alt="Info">';
html += '</div>';
new Highcharts.Chart({
 chart: {
    renderTo: 'chart_1',
    type: 'column',
    height: 350,
 },
 title: {
    text: html,
    useHTML: true,
 },
 xAxis: {
    categories: ['Processing.js', 'Impact.js', 'Other', 'Ease.js', 'Box2D.js', 'WebGL', 'DOM', 'CSS', 'Canvas', 'Javascript']
 },
 yAxis: {
    title: {
       text: 'Опрошено'
    }
 },
 series: [{
    name: 'Dev #1',
    data: [5, 10, 20, 22, 25, 28, 30, 40, 80, 90],
    color: '#FF0000',
    states: {
        inactive: {
            enabled: false
        }
    }
 }, {
    name: 'Dev #2',
    data: [15, 15, 18, 40, 30, 25, 60, 60, 80, 70],
    states: {
        inactive: {
            enabled: false
        }
    }
 }, {
    name: 'Dev #3',
    data: [1, 3, 6, 0, 50, 25, 50, 60, 30, 100]
 }],
 exporting: {
        menuItemDefinitions: {
            // Custom definition
            label: {
                onclick: function() {
                  if (this.dataTableDiv && this.dataTableDiv.style.display !== 'none') {
                    this.text = "View data table";// Присваивается, но не отображается в меню
                    this.dataTableDiv.style.display = 'none';
                    this.dataTableDiv.querySelector(".highcharts-table-caption").innerHTML = html;
                  } else {
                    this.viewData();
                    this.text = "Hide data table";// Присваивается, но не отображается в меню
                    this.dataTableDiv.style.display = '';
                    this.dataTableDiv.querySelector(".highcharts-table-caption").innerHTML = html;
                  }
                },

                text:"View data table",
            }
        },
        buttons: {
            contextButton: {
                menuItems: ["viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG", "separator", "downloadCSV", "downloadXLS", 'label']
            }
        }
    }
});
.actions, .chart {
    margin: 15px auto;
    width: 820px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/accessibility.js"></script>
<div id="chart_1" class="chart"></div>

javascript
  • 2 2 个回答
  • 36 Views

2 个回答

  • Voted
  1. Best Answer
    Neverm1ndo
    2022-08-16T21:25:24Z2022-08-16T21:25:24Z

    有一种更新方法update。您需要使用您想要的参数作为输入参数来调用此方法,而不是正常的赋值。

    代替

    label: {
     onclick: function() {
     // ...
      this.text = 'Hide data table';
     // ...
     }
    }
    

    一定是

    label: {
     onclick: function() {
     // ...
      this.exporting.update({ // Обновление menuItemDefinitions.label.text
        menuItemDefinitions: {
          label: {
             text: 'Hide data table'
          }
        }
      });
      // ...
     }
    }
    

    同理,我们将 Hide 改回 View。

    • 1
  2. Pashok
    2022-08-16T20:59:44Z2022-08-16T20:59:44Z

    解决方案比我想象的要容易。this.text = "Hide data table";我应该改写

    document.getElementsByClassName("highcharts-menu-item")[8].innerHTML = "Hide/View data table";
    

    什么解决了问题

    • 0

相关问题

  • 第二个 Instagram 按钮的 CSS 属性

  • 由于模糊,内容不可见

  • 弹出队列。消息显示不正确

  • 是否可以在 for 循环中插入提示?

  • 如何将 JSON 请求中的信息输出到数据表 Vuetify vue.js?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5