Highcharts export pictures. NET C # (II)

Source: Internet
Author: User

Because the idea of the previous one is rather messy, so rearrange the idea, and upload an example.

The highcharts.js provides the exported functionality to use SVG fixes to record the following issues, making it easier for other students to make fewer mistakes.

The following problems are primarily encountered with SVG Render Enginee:

1. In the first line of the SVG string, I get to usually have two xmlns;

2. Using Svgdocment to invoke Draw method in LinearGradient, a memory overflow occurs.

See figure below:


3, the use of Text-anchor in the text node will appear memory overflow situation.

<text style= "Font:11px/normal trebuchet MS, Verdana, Sans-serif; width:116px; Color:rgb (0, 0, 0); Cursor:default; Font-size-adjust:none; Font-stretch:normal; Fill: #000; "opacity=" 1 "text-anchor=" Middle "x=" 152.7857 "y=" 331 "> <tspan x=" 152.7857 "
      >xx High Speed </tspan >
    </text>

4. When using the text node, the text does not appear when you export.


Solution:

Question 1, use string substitution, replace "<svg xmlns=" Http://www.w3.org/2000/svg "to" <svg ";

Question 2, to modify the SVG source code, SvgLinearGradientServer.cs when the LinearGradientBrush is instantiated, because start equals end causes the problem, to determine that when start equals end, the X and y are added 1 respectively ;

Question 3, to modify the SVG source code, someone else introduced the enum svgvisibility, but still need 87 lines in SvgVisualElement.cs to modify the following:

if (this. Path!= null && Visible = = svgvisibility.visible)
For:

if (this. Path!= null && (Visible = = Svgvisibility.visible | | Visible = = Svgvisibility.inherit))

Question 4, as Svgtext reads the font size fontsize to 0, simply modifies SvgText.cs and modifies the following lines in 208 rows:

     float FontSize = this. Fontsize.todevicevalue (this);
                    if (fontsize = 0.0f)
                    {
                        fontsize = 10.0f;
                    }
                    int stringwidth;

Also modify 208 lines as follows.

-                if (_path = null | | this. Ispathdirty &&!string. IsNullOrEmpty (this. Text)
+                if (_path = null | | this. Ispathdirty) &&!string. IsNullOrEmpty (this. Text))


Then upload the demo and revise the SVG.dll to facilitate direct callable.

Because csdn can not upload files, I uploaded to the resources, convenient for everyone to download direct use.

Note Use VS2010, local test pass.

Links are as follows:

http://download.csdn.net/detail/fly_miss/5279632


The effect of opening a Web page is as follows:

The results of the export are as follows:









Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.