【问题标题】:How to add custom exporting button in highCharts?如何在 highCharts 中添加自定义导出按钮?
【发布时间】:2013-03-18 21:17:25
【问题描述】:

我们在应用程序中使用 highcharts,我想在打印和导出按钮旁边添加一个按钮。我在 jsfiddle 中有工作示例

 var chart1;
        $(document).ready(function () {

            // Add Custom button to highchart
            chart1 = new Highcharts.Chart({
                chart: {
                    renderTo: 'container1',
                    shadow: true
                },
                title: { text: 'Sales' },
                xAxis: {
                    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                                 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                },
                yAxis: { title: { text: '$'} },
                series: [{
                    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 
                           135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
                }],
                 exporting: {
                        buttons: {
                            'exportTo': {
                                _id: 'exportTo',
                                symbol: 'diamond',
                                x: -62,
                                symbolFill: '#B5C9DF',
                                hoverSymbolFill: '#779ABF',
                                onclick: function () {
                                    showDialog(this);
                                }
                            }
                        }
                    }

            });


 var showDialog = function (selectedChart) {

                var modal = $("#myModal").modal();
                $('#btnSaveImage').click(function () {
                    saveChartInNas(selectedChart);
                    modal.modal('hide');
                });
            };
        });

我们有很多图表,点击图表我想显示一个模式窗口并在保存按钮上做一些处理。而不是为所有不同页面中的所有图表创建模式和导出属性设置,我想知道是否可以某种插件或添加?如果是这样,有人可以告诉我如何实现这一点.

我不想在所有页面中添加导出逻辑。

谢谢

【问题讨论】:

标签: highcharts export


【解决方案1】:
exporting: {
                           filename: 'event-id-metadata-graph',
                            buttons: {
                                contextButton: {
                                    menuItems: [{
                                        text: 'Download PDF',
                                        onclick: function () {
                                            this.exportChart({
                                                type: 'application/pdf'
                                            });
                                        }
                                    }, {
                                        text: 'Print',
                                        onclick: function () {
                                                alert('Launch Print Table function')
                                        },
                                        separator: false
                                    }]
                                }
                            }
                        },

【讨论】:

    【解决方案2】:

    我想你是在问是否有办法将其设置为某种默认值,而不是编辑每个图表定义?

    你应该看看 Highcharts.setOptions() http://api.highcharts.com/highcharts#Highcharts.setOptions() 这允许您为所有图表设置默认值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-21
      • 1970-01-01
      相关资源
      最近更新 更多