首页 文章

如何从HighCharts中删除按钮

提问于
浏览
72

我正在使用HighCharts库创建图表,我想知道如何删除右上角的2个小按钮,您可以打印并下载图形,我想添加一个新按钮 .

也许有人可以帮助我?

6 回答

  • 190

    尝试将 exporting: { enabled: false } 添加到图表生成中 .

  • 13

    选中此项以创建新按钮:

    示例:http://jsfiddle.net/fXHB5/3496/

    exporting: {
        buttons: [
            {
                symbol: 'diamond',
                x: -62,
                symbolFill: '#B5C9DF',
                hoverSymbolFill: '#779ABF',
                _titleKey: 'printButtonTitle',
                onclick: function() {
                    alert('click!')
                }
            }
        ]
    }
    
  • 1

    替换汉堡包图标的最佳方法是禁用导航buttonOptions,然后创建自己的菜单并按documentation中的说明逐个自定义上下文 . 从这里,您可以使用自己的下拉菜单使用任何图标 .

    这会禁用汉堡包图标 .

    navigation: {
    buttonOptions: {
      enabled: false
      }
     }
    

    这是您为自己的列表自定义导出选项的方法 .

    $('#print').click(function() {
    chart.print();
    });
    $('#pdf').click(function() {
    chart.exportChart({
      type: 'application/pdf',
      filename: 'my-pdf'
     });
    });
    $('#png').click(function() {
    chart.exportChart({
      type: 'image/png',
      filename: 'my-png'
     });
    });
    $('#jpeg').click(function() {
    chart.exportChart({
      type: 'image/jpeg',
      filename: 'my-jpeg'
     });
    });
    $('#svg').click(function() {
    chart.exportChart({
      type: 'image/svg+xml',
      filename: 'my-svg'
     });
    });
    

    jsfiddle

  • 0
    exporting: {        
     contextButton: {
            enabled: false,
        }
    }
    

    您必须仅禁用contextButton .

  • 6
    exporting:false,
    

    添加上面的代码以禁用导出选项 .

  • 3

    @dgw有正确的想法删除导出按钮,但我对"and I'd like to add a new one"建议不满意,直到我意识到我应该只是按下outside the graph . 除非您的数据是静态的,否则您无需显示控件 .

    <div id="container" style="height: 400px; min-width: 600px"></div>
    <button id="button" class="autocompare">new button</button>
    

相关问题