Comments (8)
Thanks for the feedback!
Solutions
- Set the
width
parameter - Upgrade to Highcharts 3.0 (or higher)
Discussion
You are required to set the width
parameter in Highcharts (prior to version 3):
exporting: {
url: 'HighchartsExport.axd',
width: 1200
}
Try this: https://gist.github.com/Tek4/5366409
Also, see my example code here for a more complete example: https://github.com/imclem/Highcharts-export-module-asp.net/blob/master/Exporting_Demo_website/Default.aspx
The width
parameter is the number of pixels (width) of the exported image. The height is determined by the aspect ratio of the chart. You need to choose some logical value that makes sense for your application.
This export module makes no attempt to determine the width of your <div>
element, nor am I aware that Highcharts does so. I believe you would be required to perform such a determination in your own JavaScript and pass the value in the width
parameter to Highcharts.
Highcharts 3.0+
Beginning with Highcharts 3.0, the width
parameter is automatically calculated (if not set by you). New parameters scale
, sourceHeight
, and sourceWidth
were also added in Highcharts 3.0. These new parameters are not supported at this time by the ASP.NET export module (and I'm not certain they need any supporting without further study), but these parameters do affect the automatic calculation of the 'width' parameter that Highcharts performs.
Note on exporting to PDF
When exporting PDF, the width dimension is converted to inches at roughly 150 dpi. "Screen resolution" is considered to be 72 dpi, so a scalar multiplier makes the adjustment to 150 dpi---see line 232 at https://github.com/imclem/Highcharts-export-module-asp.net/blob/master/Tek4.Highcharts.Exporting/Exporter.cs
// Scalar to convert from 72 dpi to 150 dpi.
float dpiScalar = 150f / 72f;
You can change these constants, if you wish, to other than 150 dpi, as appropriate for your situation. Again, this only applies to PDF exports.
Potential code improvement
Notwithstanding these solutions, you have identified an issue which does call for a minor code change! Line 65 of the ExportChart.cs file uses '0' as the default for width
. See: https://github.com/imclem/Highcharts-export-module-asp.net/blob/master/Tek4.Highcharts.Exporting/ExportChart.cs
int width = 0;
It would make sense to change this to a sensible value like 600 to avoid the error you discovered, which should only affect Highcharts 2.x and prior.
from highcharts-export-module-asp.net.
HI, It's refreshing to see that there is people working on this handy project.
I am facing almost the same problems, but most (if not all) are on the SVG rendering engine that the project is using. Right now this library is throwing me an OutOfMemoryException on Svg.SvgLinearGradientServer.GetBrush because it is trying to create a LinearGradientBrush from (0,0) to (0,0); then after fixing that, empty text paths and so on...
Is this library the only SVG c# rendering engine? I've made a quick search and sadly the most suitable I found was this one. I've been trying to fix it but it's quite a daunting task.
Have any of you tried just recompile the library? Doing just that, with no modifications (or at least the one that was posted here about a year ago) makes it behave different (but not better).
Anyway, if I find something, I'll let you know. If any of you do, please let us know.
from highcharts-export-module-asp.net.
@daponticelli Thank you for your interest. You are correct that all of the rendering is accomplished by the .NET SVG engine which has bugs and doesn't appear to be in active development. Anyone willing to work on that project would be very appreciated!
In the alternative, one might look at how Highcharts has built their export server:
http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts
I believe this could be easily implemented on Windows, but requires the PhantomJS executable which is not a .NET component. Hence, it wouldn't work for those having only web hosting as PhantomJS needs command line access.
from highcharts-export-module-asp.net.
Thanks for taking the time to reply to my issue.
I've added a bit more information about my running environment as I believe I'm currently using the latest version of Highcharts and it still seems to send a width of 0. Either way I'm happy with the current resolution of the problem and don't have any issues setting a size.
from highcharts-export-module-asp.net.
@Vodurden I haven't tested Highcharts to know if version 3 doesn't pass along the width
parameter unless it is set manually. That's the only thing I can think of that would explain the 0, unless the auto calculation isn't occurring as I am expecting from reading the API docs. ??
from highcharts-export-module-asp.net.
Just ran into the same error myself. Highcharts 3.0.0 will send a width parameter of 0 if you don't use one of two methods to set it explicitly. Look at the exportChart function (in the HC distribution, js/modules/exporting.src.js:336). It tries to use an argument (options.width), then falls back to the chart's defaults (chart.options.exporting), but finally gives up and sends 0.
There are a few client-side automatic calculations, but they affect the SVG, not the post parameters. I suspect that they (the Highcharts authors) updated their own export service to do most of the width calculations server-side, but I haven't checked.
So, for Highcharts 3.0.0, it seems we still need to set "width" on the exportChart call or in the chart's "exporting" option.
from highcharts-export-module-asp.net.
@daponticelli There appears to be a fork of the SVG.dll project in active development here: https://github.com/vvvv/SVG --- let us know if you try it!
from highcharts-export-module-asp.net.
Please try with this version 76cf6a3 and let us know if it fixes the problem.
from highcharts-export-module-asp.net.
Related Issues (20)
- Internet Explorer title and subtitle display issue HOT 1
- Wrong image exported from Highcharts component HOT 1
- SVG.dll not converting wrapped text HOT 5
- Hide & Show Series HOT 1
- Multiple SVG to single PDF HOT 1
- HighStock with overlapped labels HOT 1
- net::ERR_CONNECTION_RESET HOT 1
- Gradient legend is not exported as it is when exporting hihmaps. HOT 4
- Testing HighStock 2.0.1 HOT 4
- Exporting Issue HighCharts Line CHart with Export server for ASP.NET HOT 13
- Subtitle rendering tiny text HOT 5
- Export ignoring label rotation HOT 2
- Exported files corrupted HOT 3
- Using with MVC HOT 1
- Can this be used to save charts to server drive? HOT 2
- Renderer text is not shown when downloading "pdf", "jpeg" and "pdf" files HOT 9
- subtitle does not export correctly HOT 1
- Needs to render in browser first, right? HOT 1
- Download as gives cropped results
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highcharts-export-module-asp.net.