【问题标题】:Printchart title in highcharts when clicking print button when chart title is null当图表标题为空时单击打印按钮时在 highcharts 中打印图表标题
【发布时间】:2013-02-27 08:48:15
【问题描述】:

嗨,我正在研究 highhchart 并坚持一个听起来很简单但找不到任何答案的观点。

我在定义 highcharts 时将图表标题设置为 null

但在导出时添加图表标题,如

 exporting: {
             filename: '<?php echo $description ; ?>',
             buttons: {
                 exportButton: {
                     menuItems: [{
                         text: 'Export Chart',
                         onclick: function () {
                             this.exportChart({}, {
                                title: {
                                    text: '<?php echo $description  ; ?>',
                                      style: {
                                            width: '450px'
                                        }
                                }
                            });
                         }
                     }, 
                     null,
                     null,
                     null]
                 }
             }
         }

在打印图表时,我无法像在导出时那样配置如何添加图表标题和其他参数。

这是我导出图表的工作小提琴 http://jsfiddle.net/4SwvV/

当图表设置为空时,导出时带有标题的导出

我不知道如何在 print 中实现这一点。打印是否允许设置这样的选项来导出图表标题/

【问题讨论】:

    标签: php javascript jquery printing highcharts


    【解决方案1】:

    您可以在导出时设置此选项,而不是 catch menuitemclick

    chartOphttp://api.highcharts.com/highcharts#exporting.chartOptions

    因此它看起来像http://jsfiddle.net/4SwvV/

    exporting: {
            filename: 'Export chart',
            chartOptions:{
                title:{
                    text:'Exported chart'
                }
            },
            buttons: {
                exportButton: {
                    menuItems: [{
                        text: 'Export Chart'
                    },
                    null,
                    null,
                    null]
                }
            }
        },
    

    编辑:

    你可以使用不完美的解决方案http://jsfiddle.net/4SwvV/4/

     title: {
            useHTML: true,
            text: '<div id="title">Example title</div>',
            style: {
                width: '300px'
            }
        },
    

    按钮:

     onclick: function () {
                            $('#title').hide();
                            chart.print();
                            $('#title').show();
                        }
    

    【讨论】:

    • 我在这里试过你的例子jsfiddle.net/4SwvV/3 听起来不错,图表选项中定义的选项反映在导出中,但当我尝试打印图表标题时,我想打印它时似乎丢失了。
    • as it states"要合并到导出图表中的其他图表选项。例如,可以为导出的图表指定特定的宽度和高度,或对打印机友好的配色方案。默认为空。 "有没有可以配置打印的图表选项
    • 这似乎确实有效并回答了我的问题jsfiddle.net/4SwvV/8,但无法使用 chart 导出所有页面。我希望导出和图表的工作方式相同:)
    猜你喜欢
    • 2020-03-20
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    相关资源
    最近更新 更多