2013-08-26 50 views
3

有没有办法将剑道图导出为JPG,PNG,BMP,GIF格式。使用下拉列表选择格式类型。如何将剑道图导出为JPG,PNG,BMP,GIF

function createChart() { 
       $("#chart").kendoChart({ 
        theme: $(document).data("kendoSkin") || "default", 
        title: { 
         text: "Internet Users" 
        }, 
        legend: { 
         position: "bottom" 
        }, 
        chartArea: { 
         //It's important that your background NOT be transparent for proper exporting 
         //of some file types - most noticeably Jpeg 
         background: "white" 
        }, 
        seriesDefaults: { 
         type: "bar" 
        }, 
        series: [{ 
         name: "World", 
         data: [15.7, 16.7, 20, 23.5, 26.6] 
        }, { 
         name: "United States", 
         data: [67.96, 68.93, 75, 74, 78] 
        }], 
        valueAxis: { 
         labels: { 
          format: "{0}%" 
         } 
        }, 
        categoryAxis: { 
         categories: [2005, 2006, 2007, 2008, 2009] 
        }, 
        tooltip: { 
         visible: true, 
         format: "{0}%" 
        } 
       }); 


      } 

      $(document).ready(function() { 
       setTimeout(function() { 
        // Initialize the chart with a delay to make sure 
        // the initial animation is visible 
        createChart(); 


       }, 400); 
      }); 

回答

1

据我所知,剑道不提供图表导出到文件的可能性,您需要使用第三方解决方案。

服务器端

如果你可以使用服务器的出口,你可以从SVG可以导出为位图的许多工具可供选择。

例如,如果您使用PHP,请参阅this question进行详细讨论。

或者在您的服务器上安装Inkscape,然后再调用inkscape inputfile.svg --export-png=exportfile.png,这与您在服务器上使用的语言或框架无关(但它需要执行外部程序的可能性)。

在这两种情况下,您需要发送到服务器的是图表的实际SVG标记(请注意,SVG实际上是一个XML文档)。这可以从包含HTML元素的Javascript中获得。

如果您使用的是ASP.NET MVC的最佳行动过程中你是去与vinbhai4u可以大大简化事项提供link

浏览器侧的

如果你不想或者不能使用的服务器,有是JavaScript(https://github.com/eligrey/FileSaver.js)库(演示:http://eligrey.com/demos/FileSaver.js/)。我认为该库只能导出到PNG,并且有一些浏览器版本限制。更多阅读:http://eligrey.com/blog/post/saving-generated-files-on-the-client-side