score:0
You can try this
var chart = $('#yourchart').highcharts();
svg = chart.getSVG();
var base_image = new Image();
svg = "data:image/svg+xml,"+svg;
base_image.src = svg;
$('#mock').attr('src', svg);
Take html of Mock and send to DB or save only the binary code .
score:4
I haven't done that before, but I believe you want to play with the index.php
file located in the exporting-server
folder.
By default Highcharts provides (for free) a web service but you can modify that and create your own web service for exporting, or do whatever you want with the chart. Look at these instructions which can be found here Export module:
"If you want to set up this web service on your own server, the index.php file that handles the POST is supplied in the download package inside the /exporting-server directory.
- Make sure that PHP and Java is installed on your server.
- Upload the index.php file from the /exporting-server directory in the download package to your server.
- In your FTP program, create directory called temp in the same directory as index.php and chmod this new directory to 777 (Linux/Unix servers only).
- Download Batik from http://xmlgraphics.apache.org/batik/#download. Find the binary distribution for your version of jre
- Upload batik-rasterizer.jar and the entire lib directory to a location on your web server. In the options in the top of the index.php file, set the path to batik-rasterier.jar.
- In your chart options, set the exporting.url option to match your PHP file location. "
score:10
I just implement this using Nobita's method. I was creating a survey that showed the user's results in a chart, uploaded the image to my server and then sent out an email with the image in it. Here's a few things to note.
I had to make a few updates to the highcharts/exporting-server/index.php file which are the following:
I changed the directory from "temp" to something else and just note that it is in 4 different locations.
I had to change shell_exec() adding "-XX:MaxHeapSize=256m" because it was giving me an error:
$output = shell_exec("java -XX:MaxHeapSize=256m -jar ". BATIK_PATH ." $typeString -d $outfile $width /mypathhere/results/$tempName.svg");
If you want it to download that image you can leave the following alone:
header("Content-Disposition: attachment; filename=$filename.$ext");
header("Content-Type: $type");
echo file_get_contents($outfile);
But, I changed this because I wanted to send back the path to the image, so I deleted the above and replace this with the image path (Note that I'm just using the temporary name.):
echo "/mypathhere/results/$tempName.$ext";
Also, this file is deleting the svg file and also the new file you made. You need to remove the code that deletes the file:
unlink($outfile);
And you can also delete the line before it if you want to keep the svg file.
Make sure to include highcharts/js/modules/exporting.js
Then, in your JS you can do something like the following:
var chart = new Highcharts.Chart();
var imageURL = '';
var svg = chart.getSVG();
var dataString = 'type=image/jpeg&filename=results&width=500&svg='+svg;
$.ajax({
type: 'POST',
data: dataString,
url: '/src/js/highcharts/exporting-server/',
async: false,
success: function(data){
imageURL = data;
}
});
The URL you are posting to is the new version of the /exporting-server/index.php. Then, you can use the imageURL however you like.
score:14
It could be done really easy with PhantomJS
. You can render Highchart
chart and save it to SVG, PNG, JPEG or PDF. The example below renders a demo Highcharts
diagram to SVG and PDF at the same time:
var system = require('system');
var page = require('webpage').create();
var fs = require('fs');
// load JS libraries
page.injectJs("js/jquery.min.js");
page.injectJs("js/highcharts/highcharts.js");
page.injectJs("js/highcharts/exporting.js");
// chart demo
var args = {
width: 600,
height: 500
};
var svg = page.evaluate(function(opt){
$('body').prepend('<div id="container"></div>');
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
width: opt.width,
height: opt.height
},
exporting: {
enabled: false
},
title: {
text: 'Combination chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
},
yAxis: {
title: {
text: 'Y-values'
}
},
labels: {
items: [{
html: 'Total fruit consumption',
style: {
left: '40px',
top: '8px',
color: 'black'
}
}]
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
},
series: {
enableMouseTracking: false,
shadow: false,
animation: false
}
},
series: [{
type: 'column',
name: 'Andrii',
data: [3, 2, 1, 3, 4]
}, {
type: 'column',
name: 'Fabian',
data: [2, 3, 5, 7, 6]
}, {
type: 'column',
name: 'Joan',
data: [4, 3, 3, 9, 0]
}, {
type: 'spline',
name: 'Average',
data: [3, 2.67, 3, 6.33, 3.33],
marker: {
lineWidth: 2,
lineColor: 'white'
}
}, {
type: 'pie',
name: 'Total consumption',
data: [{
name: 'Andrii',
y: 13,
color: '#4572A7'
}, {
name: 'Fabian',
y: 23,
color: '#AA4643'
}, {
name: 'Joan',
y: 19,
color: '#89A54E'
}],
center: [100, 80],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
}]
});
return chart.getSVG();
}, args);
// Saving SVG to a file
fs.write("demo.svg", svg);
// Saving diagram as PDF
page.render('demo.pdf');
phantom.exit();
If you save the code as demo.js
, then just run bin/phantomjs demo.js
to generate demo.svg
and demo.pdf
Source: stackoverflow.com
Related Query
- How to save an image of the chart on the server with highcharts?
- How can I make milestone lines with a GANTT chart using the highcharts library?
- How can I display crosshair labels on top of the chart with Highcharts
- How can I save HighCharts image into the project folder in PHP?
- The RTL language (Arabic) is not working with HighCharts pie chart correctly, how can I fix this?
- How to save Highcharts image on server auomatically
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- Highcharts - how to have a chart with dynamic height?
- How to export the whole page or html content with Highcharts not just the chart?
- How do you increase the performance of highcharts chart creation and rendering
- How to show a column with the value Zero in Column chart in Highcharts?
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- Highcharts Bar Chart - How to set the minimum bar width/length
- Highcharts - Scatter chart with a line connecting the dots in the series
- Add onclick event on chart made with the highcharts library
- Highcharts 3.0, area chart with stacked and unstacked series - how to fix?
- Highcharts Bubble Chart - How to move an individual point's data label (dataLabel) to the front/top
- Highcharts column + line combination chart with multiple series. Issue aligning line over the column
- How To Dynamically Truncate The Y-Axis Title On Chart Resize/Reflow In Highcharts
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- How to Build a Column Chart in Highcharts with Data Entered Dynamically Within a CMS
- how to display the title in the middle of a donut chart with legend?(react-highcharts)
- how to develop custom chart with box annotations as like attached image
- how to display 2 same highcharts without duplicate the code
- How to merge two Highcharts container with the same legend-item
- How to use Highcharts React to create chart with multiple lines for same XAxis?
- How do I change the style of the inner part enclosed by the lines(polar) chart created with highcharts?
- How to re-create the same chart in Highcharts as seen on the mock?
- Highcharts - how to export chart with different scale in one click
- Highcharts server side image generation, how to set up legend labelFormatter in callback argument
More Query from same tag
- Highchart Pie chart with partially colored slices
- How to display legend in Highcharts Waterfall Chart and make the sum column of waterfall appear in multiple colors?
- How to change label double number in highchart
- export csv from highcharts
- Highcharts tips ? How can I add a class or an id to an Hichcharts DOM component?
- highcharts scrollbar labels not appearing
- Highcharts export is navigating to demo page
- net:ERR_FAILED - My application (Ionic 4 / Angular 7) is giving an error when trying to export a Highcharts
- Trigger mousedown and include e.which in the event
- The labels are displayed but data is not displayed
- Highstock Angular value in legend
- highstock chart click get closest point
- How to use Vue bound data in Highcharts?
- HighCharts Keep Vertical Line on Click Event
- Highcharts Data Point Image
- highcharts dataLabel overflow: justify issue
- highstock chart cancel zoom area selection using "Esc"
- RevealJS and Highchart Mouse position Tooltip Issue
- Use an array of objects for series data in Highcharts
- Highcharts Export to CSV No Data Grouping
- Manually Triggering drillup event, highcharts
- Array not passing data
- jQuery Highcharts not working with JSF 2.0
- Add text over export button in Highcharts
- Just how flexible is highcharts? (Mockup attached.)
- How can i color one sector
- In Highcharts, any way we can get the plotWidth and plotHeight before rendering the chart?
- Uncaught TypeError: Cannot read property 'addPoint' of undefined ( Highstock live data)
- How to make highchart bubble chart color active of clicked bubble
- What is the format of 'date' when for highchart?