score:5
It sound like you are working on some kind of admin tool so changing the size of the chart might not be an issue. You should probably use chart.setSize(width,height) before calling getSVG().
If you can't go that route, you could also edit the SVG text directly but that wouldn't be a best practice in my opinion.
It seems that the way canvg works is it takes the scaleWidth/scaleHeight and adds a transform="scale()" to the svg based on the options you pass and the existing height/width of the svg. The problem is it doesn't change the existing height/width of the svg and resulting image. I put together a jsfiddle that does what I think you want, but it is probably not the best solution. http://jsfiddle.net/sgearhart2/EsPud/1/
var chart_svg = chart.getSVG();
chart_svg = chart_svg.replace('width="600"', 'width="1280"');
chart_svg = chart_svg.replace('height="400"', 'height="860"');
// If i had to guess, canvg does the next part but not the prior part
var dWidth = 1280/600, dHeight = 860/400;
chart_svg = chart_svg.replace(
'<svg ',
'<svg transform="scale(' + dWidth + ' ' + dHeight + ')" '
);
score:2
As on today (year 2016) I can make canvas use correct sizes of chart by passing parameters into getSVG()
function.
As example :
var chartSVG = chart.highcharts().getSVG({
exporting: {
sourceHeight: chart.highcharts().chartHeight,
sourceWidth: chart.highcharts().chartWidth,
}
});
score:7
I improved Scott Gearhart without hacks :) http://jsfiddle.net/marcalj/EsPud/7/
Most important part:
// Get chart aspect ratio
var c_ar = chart.chartHeight / chart.chartWidth;
// Set canvas size
chart_canvas.width = 1280;
chart_canvas.height = chart_canvas.width * c_ar;
canvg(chart_canvas, chart_svg, {
ignoreDimensions: true,
scaleWidth: chart_canvas.width,
scaleHeight: chart_canvas.height
});
Make sure you set fixed width and height on chart element.
Source: stackoverflow.com
Related Query
- highcharts and canvg scaling issue
- jQuery UI Tabs and Highcharts display/rendering issue
- Highcharts data series issue with ajax/json and PHP
- Highcharts Pie Chart ignores percentageDecimals tooltip setting and has floating point inaccuracy issue
- Highcharts - Global configuration with common code and unique data & Headings
- HighCharts performance issue and alternative
- Highcharts more and highcharts guage issue
- Highcharts Scaling Graph Issue
- Performance issue with Firefox on Highcharts and Highstocks
- Highcharts / Highstock scroll bar and Zoom issue
- Highcharts custom scaling on y axis - mix of linear and logarithmic
- Highcharts ; x-axis scaling issue
- resizing and positioning issue with gridster and multiple highcharts
- Highcharts bar and line issue
- canvg and highcharts how to include chart legend and keep the chart size?
- Highcharts issue when dealing with 3D pie and large labels
- Highcharts issue when dealing with 3D pie and large labels
- iScroll 4 and highcharts compatibility issue
- Highcharts - Issue with showing and hiding plot lines and bands on legendItemClick
- javascript associative array, looping, and / or scope issue with Highcharts JSON call
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Array issue in rails and highcharts
- Combined Chart Highcharts Pie plus Bar grouppadding and pointapadding issue
- Highcharts cloud issue with data source when duplicating chart
- Issue with npm and Highcharts
- Highcharts dataLabel positioning issue in FF and IE
- Issue with Datepicker UI and Highcharts and the dateFormat
- Highcharts dual yaxis scaling issue
- Highcharts legends data overlapping issue on set and update data
- how can I use rangeselector and navigation in highcharts in the given code
More Query from same tag
- Highlight point in Highcharts scatter graph?
- How to add space between plotband and first bar(red color "A" bar) in highchart
- Adding highcharts to mapbox popup from CSV?
- Highcharts Using Data from Ruby on Rails Database
- HighMaps how to update data using jQuery
- Highchart can't be displayed
- Highcharts free-form drawing content not getting exported
- highcharts zooming over line charts not working properly
- Nested json in Highcharts Stacked
- ColorAxis in percentage bar. Approach. Highcharts
- Highcharts - "Style is null or not an object"
- How to auto save highcharts as image in specific folder
- How to Add button in React Highchart Tooltip?
- Update highcharts with new set of data
- Highcharts do not render
- How do I adjust the initial range in hc_navigator
- Highcharts: collecting all charts on a page second time produces error
- Highcharts, pass Data from json on Column Click
- Produce highcharts multiple line chart from JSON / MySQL data
- Custom "compare" and axis range in Highcharts
- SVG marker on Highcharts path
- highchart stacked column total data per categories
- With highcharts, is that possible to add dataLabels below column?
- HighCharts dynamically resize renderer label or element
- Using high charts' 'rows' property from the 'data' module
- show tooltip for each point of highcharts network graph in Angular
- How to show a loading state before show the complete page?
- High Chart progress bar/Status bar
- How to color series legend in highcharts when colorbypoint is set to true
- Highchart manage state manually