highcharts / node-export-server

Highcharts Node.js export server
Other
356 stars 260 forks source link

I am looking for a way to call the hosted URL and save the response(chart) directly into a file.png/jpg. #140

Closed IamTheLegend closed 2 years ago

IamTheLegend commented 6 years ago

HI Team,

   First of all, Amazing work with Highcharts development. It is very useful in reports generation.  I would like to get some info; I have hosted the highcharts-export-module and trying to hit the URL using http-post, I am sending the data and I want to save the response data directly into a image file jpg/png. Could you please, let me know if there is a way to achieve this?.

Thanks a lot !!

qwe900 commented 6 years ago

Snipped for PHP `` $chartdata = array("constr" => "stockChart", "type" => "jpeg", "scale" => "2", "globaloptions" => "{global:{useUTC: true, }}", "infile" => "{ chart: { style: {
fontFamily: 'Helvetica' }, animation: false, height: 600, width: 950, marginTop: 50, marginBottom: 70, marginLeft: 70, marginRight: 70, plotBorderWidth: 1, borderColor: 'grey', borderWidth: 0.7, spacingTop: 15, spacingLeft: 7, spacingRight: 7, dsad }, title: { text: '$title', style: { fontSize: '20px' }, }, exporting: { enabled: false, },

            navigator: {
                enabled: false,
                },  

            scrollbar: {
                enabled: false,
                },

            credits: {
                enabled: true,
                text: '',
                style: { color: 'black',   fontSize: '12px'  }
                },

            xAxis: {

                lineColor: 'black',
                type: 'datetime',

                ordinal: false,
                startOnTick: true,
                endOnTick: true,
                minPadding: 0,
                maxPadding: 0,

                showLastLabel: false,
                showFirstLabel: false,

                },

            yAxis: {
                min: 0,
                max : $maxwert,
                startOnTick: true,
                endOnTick: true,
                showLastLabel: true,
                gridLineColor: 'black',
                gridLineDashStyle: 'dot',
                 opposite: false,
                title: {

                    text: 'Schwinggeschwindigkeit in mm/s',
                    style: {
                        color: 'black',
                        fontSize: '14px'
                    }
                },

            },

            plotOptions: {

                series: {
                    dataGrouping: {
                        enabled: false,

                    },
                    animation: false,
                    shadow: false,
                    connectNulls: false,

                    tooltip: {
                        enabled: false
                    },
                    states: {
                        hover: {
                            enabled: false,

                        }
                    }
                },
                line: {
                    lineWidth: 1.5,
                    step: 'center',
                    pointRange: 300000,

                },
            },

             legend: {
                enabled: true,
                align: 'right',
                backgroundColor: 'white',
                borderColor: 'black',
                borderWidth: 1,
                layout: 'vertikal',
                verticalAlign: 'center',
                y: 250,
                x: -5,

                shadow: false,

            },
            rangeSelector: {
                enabled: false

            },

                series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]

}, { name: 'Manufacturing', data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434] }, { name: 'Sales & Distribution', data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387] }, { name: 'Project Development', data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227] }, { name: 'Other', data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111] }] }");

// transfer all into json

$postdata = json_encode($chartdata);

$chartdata = ""; //send data to export server $url = 'http://127.0.0.1:7801'; $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $result = curl_exec($ch);

curl_close($ch);

//send data to client header("Content-type: image/jpeg");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; filename="avatar.jpg"'); echo $result;

sorry this code styling here is too hard for me :D

vidyashree09 commented 5 years ago

hi, I have same requirement if i start export server in terminal code is working fine for some time after that am getting connection error. Error:Failed to connect to 127.0.0.1 port 7801: Connection refused highcharts-export-server -enableServer 1 -port 7801 this comment if i run on server terminal am able to download image to server after some time am getting error. How do i fix this issue please help

qwe900 commented 5 years ago

hi, I have same requirement if i start export server in terminal code is working fine for some time after that am getting connection error. Error:Failed to connect to 127.0.0.1 port 7801: Connection refused highcharts-export-server -enableServer 1 -port 7801 this comment if i run on server terminal am able to download image to server after some time am getting error. How do i fix this issue please help may contact me on skype to see your issue ? xs-frost

PaulDalek commented 2 years ago

Closing issue due to inactivity.