0

is there any possibility to export charts done with hightcharts in powerpoint?else can someone help me to find a solution?

Thanx

Good D
  • 35
  • 7

2 Answers2

1

Just export it to an image (PNG or JPG) and add that image to a powerpoint slide? Most highcharts graphs have a download (export) button in the upper right corner of the chart.

Reality Extractor
  • 1,257
  • 3
  • 16
  • 25
  • ok, i thought also about this idea but is there somehow to download this image directly in one folder bc for example the browsers ask if i wanna download or no etc... but what i want to do is to download this image in one folder without any messages etc and from phppowerpoint read them. – Good D Apr 06 '13 at 17:13
  • @GoodD seems to be what you really want is to generate a highcharts image server side and import that into phppowerpoint. See http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts on how to do that. – Reality Extractor Apr 06 '13 at 23:42
0

I know this is old but I am currently trying to achieve the same thing. If you are happy to use png or jpg then I would go with phantonJS (OpenQA.Selenium.PhantomJS) to extract an svg and then any conversion mechanism to convert to png/jpg

public IList<string> ExtractSVGs(string htmlFilePath)
    {
        IList<string> SVGs = new List<string>();
        foreach (string chart in getChartIds(htmlFilePath))
        {
            SVGs.Add(ExtractSVG(htmlFilePath, chart));
        }
        return SVGs;
    }

    private IList<string> getChartIds(string htmlFilePath)
    {
        IList<string> chartIds = new List<string>();
        string whatToFind = @"  ""renderTo"": """;
        foreach (string line in (System.IO.File.ReadLines(htmlFilePath)))
        {
            if (line.StartsWith(whatToFind))
                chartIds.Add("chart" + line.Substring(line.IndexOf(whatToFind) + whatToFind.Length, 32));
        }
        return chartIds;
    }

    private string ExtractSVG(string htmlFilePath, string chartId)
    {
        var driverService = PhantomJSDriverService.CreateDefaultService();
        driverService.HideCommandPromptWindow = true;
        driverService.LoadImages = true;
        driverService.ProxyType = "none";
        driverService.LocalToRemoteUrlAccess = true;
        driverService.WebSecurity = false; // may not be necessary

        using (var driver = new PhantomJSDriver(driverService))
        {
            driver.Navigate().GoToUrl(new Uri("file:///" + htmlFilePath));
            string svg = (string)driver.ExecuteScript(String.Format("return {0}.getSVG();", chartId), null);
            driver.Close();
            return svg;
        }
    }

You could alter the JS to export directly to png but that would require linking into an export server (or having that code run locally as well).

On a side note you may need to alter the what to find depending on how you build up your html files.

russelrillema
  • 452
  • 7
  • 14