Highcharts css styles when exporting
You can pass your CSS styles in your post request to export server.
var options = {
chart: {},
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],
type: 'column'
}]
}
var chart = Highcharts.chart('container', options);
var data = {
options: JSON.stringify(options),
resources: {
// You can add your CSS styles here
css: ".highcharts-background { fill: #efefef; stroke: #a4edba; stroke-width: 2px}"
},
filename: 'test.png',
type: 'image/png',
async: true
}
var exportUrl = 'https://export.highcharts.com/';
$.post(exportUrl, data, function(data) {
var imageUrl = exportUrl + data;
var urlCreator = window.URL || window.webkitURL;
document.querySelector("#image").src = imageUrl;
fetch(imageUrl).then(response => response.blob()).then(data => {console.log(data)});
})
Live example: https://jsfiddle.net/nfbcq865/
HighChart Title text implemented HTML Style is not applying in exporting files
Answer of @Halvor Strand hits the home, but additionally there is need to change the title structure, because SVG won't generate correctly during exporting. It's happening because </br>
's, but to solve this problem, for example you can place every title line in different <span>
element with style="display: block;"
set on it. Take a look on the code:
title: {
useHTML: true,
text: '<span style="display: block;">Header Text in Line1</span><span style="display: block;">Line 2 Text</span><span style="display: block;">Line 3 Text</span>',
style: {
"text-align": "center"
}
}
Live example: http://jsfiddle.net/m052y9ud/
HighChart - How to apply override Subtitle style css in HighChart Print
You should position the subtitle element by x property:
subtitle: {
useHTML: true,
align: 'left',
text: 'SubTitle: line1 <br/> SubTitle: line2 ',
x: 100
}
Live demo: http://jsfiddle.net/BlackLabel/u4qpod2a/
You can also look at this topic: Highcharts css styles when exporting, to find out how to export chart with css styles.
Related Topics
Sublime Text Wrap Selection with Snippet
Bootstrap Breakpoints... Need Some Clarification ' Xs Sm Md Lg'
How to Combine Position: Relative and Float: Left
Space Between Border and Content/Border Distance from Content
Building a 4 Corners-Colors CSS3 Gradient
Zoom in and Out on Mouse Click with CSS
Easy Tool to Decompose Sprite Image
I Need to Scale an Entire Website Down to 80%
How to Choose The Last 2 Items in a List with CSS Nth-Child
How to Make Popup Look at The Centre of The Screen
Why Use Ems for Padding & Margins with Browsers Now Scaling Correctly
Prevent Box Shadow from Showing on a Specific Side
How to Animate a Glowing Effect on Text
Bootstrap, Making Responsive Changes to Layout
Browser Developer Tools: What Is The Position of The HTML Element
How to Make a Pie Chart in CSS
Overlay a Background-Image with an Rgba Color, with a CSS3 Transition