0

I am using highstock library to generate chart on my website. I want to use the same charts in my pdf reports. I found these articles on their website:

http://www.highcharts.com/component/content/article/2-articles/news/56-improved-image-export-with-phantomjs

http://www.highcharts.com/component/content/article/2-articles/news/52-serverside-generated-charts

I installed phantomjs in C directory and highcharts-convert.js in the same directory as HighStock. In C# I am starting a process to execute phnatom JS. This is the code:

Process process = new Process();
process.StartInfo.WorkingDirectory = "C:\\Phantom JS\\phantomjs-1.9.7-windows";
process.StartInfo.FileName = "phantomjs.exe";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;          
process.StartInfo.Arguments = "phantomjs highcharts-convert.js -infile options.js -outfile chart-output.png -scale 2.5 -width 300";          
process.Start();   

These are the contents of options.js (copied from highcharts example)

{
    infile: {
            xAxis: {
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            }
        series: [
            {
                data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
            }]
    }
}

The process runs but there is no output-chart being generated. How can I find if output chart is generated and if yes then where is it located?

Chris Haas
  • 53,986
  • 12
  • 141
  • 274
AM0
  • 165
  • 2
  • 4
  • 20
  • maybe `C:\Phantom JS\phantomjs-1.9.7-windows\chart-output.png` ? – L.B Jul 02 '14 at 21:30
  • It's not there and neither in the location where highstock is installed. – AM0 Jul 02 '14 at 21:32
  • Then run it at console and see whether it prints an error. – L.B Jul 02 '14 at 21:34
  • Yes. It says parse error. – AM0 Jul 02 '14 at 21:45
  • You should [capture and log standard error and standard output](http://stackoverflow.com/a/2909111/231316) and log them somewhere. – Chris Haas Jul 02 '14 at 21:58
  • process.StandardError.ReadToEnd() says "cannot open phantomjs\r\n" andprocess.StandardOutput.ReadToEnd() shows "". – AM0 Jul 02 '14 at 22:19
  • The first non-switch parameter to phantomjs is the JavaScript file that you want to execute. You are asking phantomjs to execute a file called `phantomjs`. Try removing that from your arguments. – Chris Haas Jul 02 '14 at 22:33
  • Now it gives the error "Cant open highcharts-convert.js. I tried to put phantomjs.exe in the same folder as highstock but the same error remained. – AM0 Jul 02 '14 at 22:43
  • I put absolute path to highcharts-convert.js file and now there's no error but still no output. – AM0 Jul 02 '14 at 22:59

0 Answers0