Export chart does not work with FlexPie

Posted by: viplav.setia on 18 November 2020, 6:56 pm EST

    • Post Options:
    • Link

    Posted 18 November 2020, 6:56 pm EST

    Hi

    I have a export function to save the chart as an image.

      Export:
            function (pDivHost) { 
               var pChart = wijmo.Control.getControl(pDivHost);
                    if (pChart != null && pChart.hostElement != null)
                        pChart.saveImageToFile(pChart.hostElement.id + '.png');
                
            },
    

    First I create a bar chart and I am able to print it.

    Then I display a Pie chart after calling these functions:

     PieChart: function (pDivHost, pChart)
    {
    var pDivHostName = null;
    
     pDivHostName = pDivHost.id;
    
          while (pDivHost.children.length)
          {
            pDivHost.removeChild(pDivHost.children[0]);
          }
    
    pChart.dispose();
    
    var VarPieChart = new wijmo.chart.FlexPie('#' + pDivHostName,
                {
                  header: pChart.header,
                  itemsSource: pChart.itemsSource,
                  binding: 'value',
                  bindingName: 'name',
                  dataLabel:
                  {
                    position: wijmo.chart.PieLabelPosition.Radial,
                    content: "{value}"
                  },
                });
    }
    
    

    But after displaying the Piechart when I call my export function the getControl method returns null.

    What am I missing here?

    Also chart interaction (zoom and pan) does not work with FlexPie.

  • Posted 19 November 2020, 3:48 pm EST

    Hi Viplav,

    We are sorry but we were unable to replicate the issue at our end. Please refer to the sample link below that we used to replicate the issue:

    https://stackblitz.com/edit/js-p58odq

    Can you let us know whether we are missing something in order to replicate your issue? The issue may also be related to a specific version, so, can you let us know the exact version which you are using?

    Also chart interaction (zoom and pan) does not work with FlexPie.

    The chart interaction are not supposed to work with the pie chart because the zooming and panning are done on the chart’s axis and since the pie chart does not have any axis, these operations cannot be applied to it.

    Regards,

    Ashwin

  • Posted 19 November 2020, 6:41 pm EST

    Hi Ashwin

    Version is wijmo-5.20182.500.

    I solved it by passing both charts as parameters for export and checking which chart has the host element.

    
    Export:
        function (pBarChart, pPieChart)
        {
          var VarProg = "PrintChart";
          var pChart = null;
          try
          {
            //var pChart = wijmo.Control.getControl(pDivHost);
            if (pBarChart != null && pBarChart.hostElement != null)
              pChart = pBarChart;
            else if (pPieChart != null && pPieChart.hostElement != null)
              pChart = pPieChart
    
            if (pChart != null && pChart.hostElement != null)
              pChart.saveImageToFile(pChart.hostElement.id + '.png');
          }
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels