In the WinForms control I am attempting to display a particular font and
font size, and yet they render smaller than other controls on the form
using the same font and font size. Below is the rendering code. Notice that
I set "pane.IsFontsScaled = false", which does seem to work - the font size
remains fixed regarless of the size of the graph control. But the lines
like "pane.XAxis.Scale.FontSpec.Size = Font.SizeInPoints", in which I am
attempting to use exactly the same font size in the graph as is used on the
form, do not seem to work properly. I have debugged it and verified that
these lines are passing the correct font name and size to the FontSpec
object, but they are rendered too small. To reproduce this bug, create a
Windows Form control, put a ZedGraph control on it, and hook up the code
below to render the graph. Also, put a Button on the form and notice how
the font size of the button label does not match the font size in the
chart.
private void CreateGraph(ZedGraphControl zed) {
GraphPane pane = zed.GraphPane;
// Set fonts
pane.IsFontsScaled = false;
pane.XAxis.Scale.FontSpec.Family = Font.FontFamily.Name;
pane.XAxis.Scale.FontSpec.Size = Font.SizeInPoints;
pane.YAxis.Scale.FontSpec.Family = Font.FontFamily.Name;
pane.YAxis.Scale.FontSpec.Size = Font.SizeInPoints;
pane.Title.FontSpec.Family = Font.FontFamily.Name;
pane.Title.FontSpec.Size = Font.SizeInPoints;
pane.YAxis.Type = AxisType.Date;
string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger",
"Leopard" };
double[] y = { 100, 115, 75, 22, 98, 40 };
double[] y2 = { 90, 100, 95, 35, 80, 35 };
double[] y3 = { 80, 110, 65, 15, 54, 67 };
double[] y4 = { 120, 125, 100, 40, 105, 75 };
BarItem myBar = pane.AddBar("Curve 1", null, y, Color.Red);
myBar.Bar.Fill = new Fill(Color.Red, Color.Red, Color.Red);
myBar.Bar.Border = new Border(Color.Red, 1);
myBar = pane.AddBar("Curve 2", null, y2, Color.Blue);
myBar.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue);
pane.XAxis.Scale.TextLabels = labels;
pane.XAxis.Type = AxisType.Text;
pane.Fill.Color = SystemColors.Control;
pane.Fill.Type = FillType.Solid;
pane.Chart.Fill.Color = SystemColors.Control;
pane.Chart.Fill.Type = FillType.Solid;
pane.Chart.Border.IsVisible = false;
pane.XAxis.MajorTic.Size = 0;
pane.YAxis.IsAxisSegmentVisible = false;
zed.AxisChange();
}
Nobody/Anonymous
WinForms Control
None
Public
|
Date: 2008-02-16 23:10
|
|
Date: 2008-01-14 19:00
|
|
Date: 2008-01-13 21:39
|
|
Date: 2008-01-13 21:25
|
|
Date: 2008-01-13 21:13
|
|
Date: 2008-01-13 20:57
|
| Field | Old Value | Date | By |
|---|---|---|---|
| status_id | Open | 2008-02-16 23:10 | jchampion |
| close_date | - | 2008-02-16 23:10 | jchampion |