2013-03-15 81 views
1

我是highchart的新手,正在使用它在我的网页上显示条形图。但是图表在打印时没有显示。只有X轴和Y轴用值打印,而不是打印。 我正在使用IE8。条形图在IE8模式下可见(打印时),但在IE8兼容模式下不可见。我需要使它在IE默认模式下工作,即IE8 compat。模式。highchart在打印时不显示条形图

任何人都可以帮助我解决这个问题。

我在我的js函数中添加了一个代码块,我在一个lightbox窗口中打印了我的highchart。

 var chart = new Highcharts.Chart({ 
     chart: { 
      renderTo: 'containerDivID', 
      type: 'column' 
     }, 
     title: { 
      text: '' 
     }, 
     xAxis: { 
       categories: xDataValues 

     }, 
     yAxis: { 
      min: 0, 
      title: { 
       text: '' 
      } 
     }, 
     tooltip: { 
      formatter: function() { 
       return ''+ 
        this.x +': '+ this.y +' kr'; 
      } 
     }, 

     plotOptions: { 
      column: { 
       stacking: 'normal', 
       borderWidth: 1, 
       dataLabels: { 
        enabled: false, 
        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white' 
       } 
      } 
     } 
     , 
     yAxis: { 
      labels: { 
       formatter: function() { 
        return this.value; 
       } 
      }, 
      title:{ 
       text: '' 
      } 
     }, 
     series: [ 
      { 
      name: 'YAxis', 
      color: '#37789F', 
      data: yDataValues 
     } 

     ], 
     credits:{ 
      enabled: false 
     } 
    }); 

在这张灯箱中,我有一个按下这个按钮的打印按钮,我打电话给window.print()来打印页面。在我的打印页面上,我可以看到y轴和x轴以及那里的数据,但看不到我的条形图。但是,如果我将IE8模式从兼容模式更改为IE8标准模式,则可以在打印时看到我的图表。

问候, 安迪

+0

欢迎StackOverflow上。你可以编辑你的问题,包括一些你到目前为止的代码。我们无法解决您的问题,除非我们能够看到您在代码中做了什么。谢谢。 – Melon 2013-03-15 05:46:05

+0

嗨LydOn,感谢您的快速回复。我已经添加了snipet代码以更好地理解我的问题。 – Andi 2013-03-15 09:54:36

回答

0

对我而言,我没有使用print()函数来打印图表,因为我需要在图表中打印额外的数据;因为我的图表是报告的一部分。

亲切找到自定义打印功能我写道:

function printReport() { 
    w = window.open(); 
    var svg = myChart.getSVG(); 

    //clone the div you want to print which contains your chart 
    var toprint = $('#bs-results') .clone(); 

    //replace the chart with the svg 
    toprint.find('#graph_div').html(svg); 

    //right the output to print it 
    w.document.write(toprint.html()); 

    w.print(); 
    w.close(); 
}