简体   繁体   English

Highcharts - 导出模块

[英]Highcharts - Exporting Module

I am using highcharts to generate graphical data pulled from a database. 我正在使用highcharts来生成从数据库中提取的图形数据。

I am having trouble using the exporting module. 我在使用导出模块时遇到问题。 I have included the exporting property: 我已经包含了出口财产:

exporting{
  enabled:true
}

but the buttons do not appear... 但按钮没有出现......

I have also linked the exporting.js to the file too...no buttons appear.. 我也将exports.js链接到文件中......没有按钮出现..

Has anyone else had this issue? 其他人遇到过这个问题吗?

EDIT: 编辑:

Here is the code: 这是代码:

$.ajax({
               type:"POST",
               url: "retrievechartdata.php",
           data: {questionId:qId, questionIdTwo:qIdTwo, title:title, titleTwo:titleTwo, from:from, to:to},
               dataType: "json",
               success: function(data) {
         //$("#response").html("<div class='successMessage'>"+ data.valuesTwo +"</div>");   
                   var maxY = parseInt(data.max) + 1;          
                   var minY = parseInt(data.min);          

           if(minY > 0){
             minY = 0;
           }else{
             minY -= 1;
           }

           var cdata = new Array();  
           cdata= data.values.split(',');  
           for(var i=0;i<cdata.length;i++)  
           {  
             cdata[i]= parseInt(cdata[i]);  
           } 
           var leg = false;
           var title = data.questionTitle;
           if(data.valuesTwo != "FALSE"){
             leg = true;
             title += " & "+data.questionTitleTwo; 
             var cdataTwo = new Array();  
             cdataTwo = data.valuesTwo.split(',');  
             for(var i=0;i<cdataTwo.length;i++)  
               {  
             cdataTwo[i]= parseInt(cdataTwo[i]);  
               } 
           }
              chart = new Highcharts.Chart({
      chart: {
         renderTo: 'container',
         zoomType: 'x',
         spacingRight: 20
      },
      credits: {
        enabled: false
      },
       title: {
         text: title
      },
       subtitle: {
         text: document.ontouchstart === undefined ?
            'Click and drag in the plot area to zoom in' :
            'Drag your finger over the plot to zoom in'
      },
      xAxis: {
         type: 'datetime',
         maxZoom: 14 * 24 * 3600000, // fourteen days
         lineWidth: 1,
         lineColor: '#999999',
         title: {
            text: 'Date' 
         }
      },
      yAxis: {
         title: {
            text: data.questionTitle
         },
     labels: {
        y: 2
     },
     lineWidth: 1,
         lineColor: '#999999',
         gridLineWidth: 1,
     gridLineColor: '#eaeaea',
     min: minY,
     max: maxY, 
         startOnTick: false,
         showFirstLabel: false
      },
      tooltip: {
         shared: true               
      },
      legend: {
         enabled: leg
      },
      plotOptions: {
         area: {
            Color: {
               linearGradient: [0, 0, 0, 600],
               stops: [
                  [0, 'rgb(69, 114, 167)'],
                  [1, 'rgba(2,0,0,0)']
               ]
            },
            lineWidth: 1,           
            marker: {
               enabled: false,
               states: {
                  hover: {
                     enabled: true,
                     radius: 5
                  }
               }
            },
            shadow: false,
            states: {
               hover: {
                  lineWidth: 1                  
               }
            }
         }
      },

      series: [{
         type: 'spline',
         name: data.questionTitle,
         pointInterval: 24 * 3600 * 1000,
     pointStart: Date.UTC(data.year, data.month, data.day),
     data: cdata,
     lineColor:  '#f6a828',
     color: '#418ed6'
      },
      {
         type: 'spline',
         name: data.questionTitleTwo,
         pointInterval: 24 * 3600 * 1000,
     pointStart: Date.UTC(data.year, data.month, data.day),
     data: cdataTwo,
     lineColor:  '#808080',
     color: '#ff0000'
      }],
      exporting: {
        enabled: true
      }
   })

Which version of Highcharts you are using? 您使用的是哪个版本的Highcharts? Which version of jQuery? 哪个版本的jQuery?

Currently is the v2.1.6, I recommend you use the latest release because they are continuously fixing bugs, adding new functionality, etc. 目前是v2.1.6,我建议你使用最新版本,因为它们不断修复bug,添加新功能等。

Prior to v2.0 there is no support to the exporting feature 在v2.0之前,不支持导出功能

The only things you need to do in order to bring the exporting module working are: 为了使导出模块正常工作,您需要做的唯一事情是:

1- First: Add the js script after the highcharts script, like this: 1- 首先:在highcharts脚本之后添加js脚本,如下所示:

    ...
    <script type="text/javascript" src="../js/highcharts.js"></script>
    <!-- 1b) Optional: the exporting module -->
    <script type="text/javascript" src="../js/modules/exporting.js"></script>
    ...

The exporting module is enabled by default, so there is no need to have the code you posted, so you can remove it: 默认情况下启用导出模块,因此无需拥有您​​发布的代码,因此您可以将其删除:

exporting{
  enabled:true
}

2- Second: Be sure to publish the exporting-server/index.php file correctly. 2- 秒:确保正确发布exporting-server/index.php文件。

Here you have what the official documentation reads about the exporting module installation: 在这里,您可以获得有关导出模块安装的官方文档:

  1. Exporting module 导出模块

From version 2.0 an exporting module is available for Highcharts, which allows users to download images or PDF's of your charts. 从版本2.0开始,Highcharts可以使用导出模块,允许用户下载图表的图像或PDF。 This module consists of an extra JavaScript file, exporting.js, and a web service or server module written in PHP. 该模块包含一个额外的JavaScript文件exports.js,以及用PHP编写的Web服务或服务器模块。 Highslide Software offers the exporting web service free of charge. Highslide Software免费提供出口Web服务。 If you include the exporting module in your charts, two buttons will appear in the upper right. 如果在图表中包含导出模块,则右上角会出现两个按钮。 One button prints the chart, which is done on the client side only. 一个按钮打印图表,仅在客户端完成。 The other button handles exporting. 另一个按钮处理导出。 By default, an SVG representation of the chart is sent by POST to http://export.highcharts.com , where it is converted using Apache's Batik converter to PDF, PNG or JPEG. 默认情况下,图表的SVG表示由POST发送到http://export.highcharts.com ,在那里使用Apache的Batik转换器将其转换为PDF,PNG或JPEG。

See the navigation and exporting reference items for a full documentation for the options available. 有关可用选项的完整文档,请参阅导航和导出参考项。 Also see under "Methods and Properties" in the reference for members releated to exporting. 另请参阅与导出相关的成员的参考中的“方法和属性”。

Here you can see the configuration options regarding the exporting module: http://www.highcharts.com/ref/#exporting 在这里,您可以看到有关导出模块的配置选项: http//www.highcharts.com/ref/#exporting

Hope it helps you. 希望它能帮到你。

Make sure the script tag has 确保脚本标记有

type="text/javascript" 类型= “文本/ JavaScript的”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM