|
makechart2 and SVG |
Posted by Marc Des Rosiers on Feb-03-2017 07:40 |
|
Hi Peter,
I use version 6.1.1.0 with ASP.NET
Because the application will run on multiple servers with load balancer, I have to stream my charts, so I do as follows:
In code behind:
Protected base64stringPieChart As String
... build the chart code ...
Dim myByte As Byte() = c.makeChart2(5)
base64stringPieChart = Convert.ToBase64String(myByte)
On the page I have:
<img src="data:image/svg;base64,<%=base64stringAssets%>" width="800" height="350" alt="" />
If I use '5' in makechart2 (SVG format), I get a blank page. If I use '0' (PNG format) the chart shows.
What should I do? I will need SVG because the charts have to be sharp for printing the output.
Thanks,
Marc |
Re: makechart2 and SVG |
Posted by Peter Kwan on Feb-04-2017 02:06 |
|
Hi Marc Des Rosiers,
I have tried your code myself, and it works normally in my case if I use "image/svg+xml" as the MIME type. (Note that the SVG MIME type is not "image/svg". It is "image/svg+xml".
For server farms with load balancer, apart from using the data protocol to stream the chart images, there are three other methods:
(a) Make sure your load balancer is configured to support session affinity. It means the same user is always serviced by the same server, while different users can be services by different servers. Most load balancer supports session affinity, as it is a common requirement. As the same user is serviced by the same server, a chart produced by server can be delivered to the user using a second HTTP connection.
(b) Make sure the servers have consistent session state. As this is also a common requirement, the ASP.NET system has built-in support for consistent session state, such as by using the ASP.NET session state service. You just need to configure the system to use this feature. See:
https://msdn.microsoft.com/en-us/library/ms178586.aspx
As the servers have consistent session state, a chart created by one server can be delivered to the user from a different server. (In ChartDirector, the chart image is stored in the session state.)
(c) Instead of streaming the chart with the data protocol, you can create the chart as a temporary image file. As long as the image file is on a shared drive that is visible to all servers, the chart created by one server can be delivered to the user from a different server. ChartDirector has a built-in method to create the temporary file. See:
http://www.advsofteng.com/doc/cdnet.htm#outputviewer.htm
From my experience, most of our clients would prefer the session affinity method, as it only needs to be configured once in the load balancer instead of in all the servers and does not require modifying code, and it works for applications whether it is using session state or other methods.
Regards
Peter Kwan |
Re: makechart2 and SVG |
Posted by Marc Des Rosiers on Feb-04-2017 05:12 |
|
Thanks, that's very helpful. The chart shows perfectly with svg+xml.
Your load balancer comments are very helpful as well.
Cheers! |
|