2013-04-06 2 views

답변

1

그냥 이미지 (PNG 또는 JPG)로 내보낼 및 파워 포인트 슬라이드에 해당 이미지를 추가? 대부분의 highcharts 그래프에는 차트의 오른쪽 위 모서리에 다운로드 (내보내기) 버튼이 있습니다.

+0

좋아, 나도이 생각에 대해 생각하지만, 어떻게 든이 이미지를 한 폴더에 직접 다운로드 할 수 있습니다. 예를 들어 브라우저에서 다운로드 할 것인지 묻는 지 묻습니다.하지만 할 일은이 이미지를 다운로드하는 것입니다. 메시지가없는 한 폴더에 저장하고 phppowerpoint에서 읽습니다. –

+0

@GoodD는 하이 차트 이미지 서버 측을 생성하고이를 phppowerpoint로 가져 오는 것이 정말로 원하는 것처럼 보입니다. 방법은 http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts를 참조하십시오. –

0

나는 이것이 오래된 것을 알고 있지만, 나는 현재 같은 것을 성취하려고 노력 중이다. 당신은 PNG/JPG로 변환하는 SVG 후 어떤 변환기구를 추출 후, 나는 phantonJS (OpenQA.Selenium.PhantomJS)로 갈 것 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; 
     } 
    } 

당신은 JS를 변경할 수 있습니다 png로 직접 내보내려면 내보내기 서버에 링크해야합니다 (또는 해당 코드가 로컬로도 실행되도록해야합니다).

참고로 html 파일을 작성하는 방법에 따라 찾을 대상을 변경해야 할 수도 있습니다.

관련 문제