Printing Sharpplot Labels
5 posts
• Page 1 of 1
Printing Sharpplot Labels
I'm investigating SharpPlot, and running the pie chart sample below that returns SVG. When I put this in an HTML page it displays nicely in the MS Web Browser Control, but when I print it using the same control or various other user agents, the text labels do not print.
Should the labels print?
Should the labels print?
∇ {svg}←MyChart;⎕USING;data;exp;key;sp
⎕USING←'System.Drawing,system.drawing.dll' 'System.Drawing.Imaging' 'Causeway,sharpplot.dll'
data←33 18 12 10
exp←0 0 0 20
key←'UK' 'France' 'Italy' 'Ireland'
sp←⎕NEW SharpPlot ⍝ Default size
sp.Heading←'Sample pie chart' ⍝ Property
sp.PieChartStyle←PieChartStyles.ValueTags ⍝ Flag property with single flag
sp.KeyStyle←KeyStyles.(CenterAlign+BottomAlign) ⍝ Flag property with multiple flags
sp.SetKeyText(⊂key) ⍝ Need to enclose the key vector because it is a single argument, rather than a list of arguments
sp.SetColors ⊂Color.(Navy Maroon Teal Green) ⍝ Need to enclose the vector because it is a single argument
sp.SetMargins(42 48 36 18) ⍝ No need to enclose because the 4-item vector maps to 4 arguments
sp.DrawPieChart(data exp) ⍝ No need to enclose here because the 2-item vector maps to 2 different arguments
sp.SaveImage('samplepie.png' ImageFormat.Png) ⍝ Save the chart as a PNG image, at default size
svg←sp.RenderSvg ⍬ ⍝ Return SVG image source
∇
- paulmansour
- Posts: 420
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Printing Sharpplot Labels
I am unable to reproduce your issue (I believe the labels should print) on
After doing,
I am able to view the svg in Firefox, Chrome and Internet Explorer and using Microsoft Print to PDF the labels are still there
However, on 18.0 and 18.1, I get the following errors:
Which my guess is something .NET related as 18 is using
Which versions of things are you using?
- Code: Select all
]version
Dyalog 17.0.35960 64-bit Unicode, BuildID 38943482
OS Windows 10 or Windows Server 2016 (10.0.19042) 64-bit
SALT 2.8
UCMD 2.3
.NET 4.0.30319.42000
WS 17.0
After doing,
- Code: Select all
svg←MyChart
svg⎕NPUT'pie.svg'
I am able to view the svg in Firefox, Chrome and Internet Explorer and using Microsoft Print to PDF the labels are still there
However, on 18.0 and 18.1, I get the following errors:
- Code: Select all
EXCEPTION: Index was outside the bounds of the array.
MyChart[13] sp.SaveImage('samplepie.png'ImageFormat.Png) ⍝ Save the chart as a PNG image, at default size
∧
EXCEPTION: Index was outside the bounds of the array.
MyChart[14] svg←sp.RenderSvg ⍬ ⍝ Return SVG image source
∧
Which my guess is something .NET related as 18 is using
- Code: Select all
.NET .NET Framework 4.8.4341.0
- Code: Select all
.NET 4.0.30319.42000
Which versions of things are you using?
- RichardP|Dyalog
- Posts: 30
- Joined: Fri Oct 12, 2018 3:05 pm
Re: Printing Sharpplot Labels
Richard,
Thanks for response.
Ok, the way you tried it worked fine for me too. It must be something to do with the fact or way that I have it embedded in a larger HTML document.
I will investigate more....
Thanks for response.
Ok, the way you tried it worked fine for me too. It must be something to do with the fact or way that I have it embedded in a larger HTML document.
I will investigate more....
- paulmansour
- Posts: 420
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Printing Sharpplot Labels
Ok, found the problem. My CSS (specifically for printing) starts out with this:
It is the font size setting that is causing the problem. If I remove it, the SVG chart labels will print. I don't think it is inappropriate to default the font size like this for print media, but maybe I should do it another way.
Also, I would not have thought that it would affect the SVG coming out of Sharpplot, which appears to have specific font size info, but I'm just learning about SVG....
* {
box-sizing: border-box;
font-size: 8pt;
margin: 0;
padding: 0;
}
It is the font size setting that is causing the problem. If I remove it, the SVG chart labels will print. I don't think it is inappropriate to default the font size like this for print media, but maybe I should do it another way.
Also, I would not have thought that it would affect the SVG coming out of Sharpplot, which appears to have specific font size info, but I'm just learning about SVG....
- paulmansour
- Posts: 420
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Printing Sharpplot Labels
This old stack overflow question solves the problem:
https://stackoverflow.com/questions/206 ... -font-size
Instead of using * to set the font, use the <body> selector. This works even though the SVG is under the body tag. I guess using * to reset the font for a document is not an appropriate technique... probably I don't even really understand what the * is doing...
https://stackoverflow.com/questions/206 ... -font-size
Instead of using * to set the font, use the <body> selector. This works even though the SVG is under the body tag. I guess using * to reset the font for a document is not an appropriate technique... probably I don't even really understand what the * is doing...
- paulmansour
- Posts: 420
- Joined: Fri Oct 03, 2008 4:14 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group