jjzjj

javascript - Highcharts - 导出模块

coder 2024-05-11 原文

我正在使用 highcharts 生成从数据库中提取的图形数据。

我在使用导出模块时遇到问题。我已经包含了导出属性:

exporting{
  enabled:true
}

但是按钮没有出现...

我也将 exporting.js 链接到该文件...没有出现按钮..

还有其他人遇到过这个问题吗?

编辑:

代码如下:

$.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
      }
   })

最佳答案

您使用的是哪个版本的 Highcharts?哪个版本的 jQuery?

目前是v2.1.6,我建议你使用最新的版本,因为他们在不断地修复错误,添加新功能等。

在 v2.0 之前不支持导出功能

为了使导出模块正常工作,您唯一需要做的事情是:

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>
    ...

导出模块是默认启用的,所以不需要你贴的代码,所以你可以删除它:

exporting{
  enabled:true
}

2- 其次一定要正确发布exporting-server/index.php文件。

这里是官方文档中关于导出模块安装的内容:

  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. This module consists of an extra JavaScript file, exporting.js, and a web service or server module written in PHP. Highslide Software offers the exporting web service free of charge. 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.

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.

在这里您可以看到有关导出模块的配置选项:http://www.highcharts.com/ref/#exporting

希望对你有帮助。

关于javascript - Highcharts - 导出模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7169869/

有关javascript - Highcharts - 导出模块的更多相关文章

  1. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  2. ruby-on-rails - Ruby net/ldap 模块中的内存泄漏 - 2

    作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代

  3. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  4. ruby - 当使用::指定模块时,为什么 Ruby 不在更高范围内查找类? - 2

    我刚刚被困在这个问题上一段时间了。以这个基地为例:moduleTopclassTestendmoduleFooendend稍后,我可以通过这样做在Foo中定义扩展Test的类:moduleTopmoduleFooclassSomeTest但是,如果我尝试通过使用::指定模块来最小化缩进:moduleTop::FooclassFailure这失败了:NameError:uninitializedconstantTop::Foo::Test这是一个错误,还是仅仅是Ruby解析变量名的方式的逻辑结果? 最佳答案 Isthisabug,or

  5. ruby - 获取模块中定义的所有常量的值 - 2

    我想获取模块中定义的所有常量的值:moduleLettersA='apple'.freezeB='boy'.freezeendconstants给了我常量的名字:Letters.constants(false)#=>[:A,:B]如何获取它们的值的数组,即["apple","boy"]? 最佳答案 为了做到这一点,请使用mapLetters.constants(false).map&Letters.method(:const_get)这将返回["a","b"]第二种方式:Letters.constants(false).map{|c

  6. ruby - 模块嵌套代码风格偏好 - 2

    我的假设是moduleAmoduleBendend和moduleA::Bend是一样的。我能够从thisblog找到解决方案,thisSOthread和andthisSOthread.为什么以及什么时候应该更喜欢紧凑语法A::B而不是另一个,因为它显然有一个缺点?我有一种直觉,它可能与性能有关,因为在更多命名空间中查找常量需要更多计算。但是我无法通过对普通类进行基准测试来验证这一点。 最佳答案 这两种写作方法经常被混淆。首先要说的是,据我所知,没有可衡量的性能差异。(在下面的书面示例中不断查找)最明显的区别,可能也是最著名的,是你的

  7. ruby-on-rails - 使用 config.threadsafe 时从 lib/加载模块/类的正确方法是什么!选项? - 2

    我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co

  8. ruby-on-rails - Controller 中的 Rails 辅助模块 - 2

    我有一个Controller,我想为这个Controller创建一个助手,我可以在不包含它的情况下使用它。我尝试像这样创建一个与Controller同名的助手classCars::EnginesController我创建的助手是moduleCars::EnginesHelperdefcheck_fuellogger.debug("chekingfuel")endend我得到的错误是undefinedlocalvariableormethod`check_fuel'for#有没有我遗漏的约定? 最佳答案 如果你真的想在Controll

  9. ruby-on-rails - 具有同名的模块和类 - 2

    我有一个模块stat存在于目录结构中:lib/stat_creator/stat/在lib/stat_creator/stat.rb中,我在lib/stat_creator/stat/目录中有我需要的文件,以及:moduleStatCreatormoduleStatendend当我使用该模块时,我将这些类称为StatCreator::Stat::Foo.new现在我想要一个存在于应用程序中的根Stat类。我在app/models中制作了我的Stat类,并在routes.rb中进行了设置。但是,如果我转到Rails控制台并尝试在应用程序/模型中使用Stat类,例如:Stat.by_use

  10. ruby-on-rails - 使用 javascript 更改数据方法不会更改 ajax 调用用户的什么方法? - 2

    我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的

随机推荐