Jump to content
Software FX Community

Histogram: Vertical gridlines are always dotted, even when set solid in the axis definition


Recommended Posts

I've got a requirement to create charts that are exportable to good old-fashioned Windows Metafile format, so that they can be displayed in a Rich Text Box.  GDI+ has problems with anything other than solid lines in WMFs (it dithers them), so all the lines have to be solid.

I've created a chart control on a form and have set all the axis and gridline styles that I can find to solid black.  The designer contains the code in Listing 1, if anyone wants to check whether I've simply missed something.  I've taken out the usual location, dock etc. properties from that listing.

When the chart is displayed using the code in Listing 2, the horizontal gridlines are indeed solid black.  However, the vertical gridlines (coming up from the numerical labels on the X axis) are dotted - and probably the default colour, though I've not put an eyedropper on it to check.  As a result, these lines are dithered in the WMF output, making the package unusable for the purpose for which it was purchased.

How can I set the vertical gridlines to be solid, and preferably black, in this case?

Thanks in advance for any suggestions,

- Peter

-- Listing 1 --
  this.chart.AxesStyle = ChartFX.WinForms.AxesStyle.Math;
  this.chart.AxisX.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisX.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid;
  this.chart.AxisX.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisX.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisX.Title.Text = "X Axis";
  this.chart.AxisY.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisY.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid;
  this.chart.AxisY.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisY.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisY.Title.Text = "Y Axis";
  this.chart.AxisY2.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisY2.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid;
  this.chart.AxisY2.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  this.chart.AxisY2.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  solidBackground1.AssemblyName = "ChartFX.WinForms.Adornments";
  this.chart.Background = solidBackground1;
  this.chart.Border = new ChartFX.WinForms.Adornments.SimpleBorder(ChartFX.WinForms.Adornments.SimpleBorderType.Color, System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(125)))), ((int)(((byte)(138))))));
-- End of Listing 1 --

-- Listing 2 --
  private void SetChartFromOptions()
  switch (options.ChartType)
  case ChartExplorerChartType.Histogram:
  ChartFX.WinForms.Statistical.Histogram gallery = statistics1.Gallery.Histogram;
  chart.GalleryAttributes = gallery;
  gallery.ShowNormal = chkShowNormal.Checked;
  chart.AxisY.Title.Text = "Count";
  throw new ArgumentOutOfRangeException("options.ChartType", options.ChartType, "Unknown chart type");


  // Find how many series
  int seriesNumber = 0;
  foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables)
  if (v.IsDoubleVariable)
  chart.Data.Series = seriesNumber;
  chart.Data.CommitChanges(); // TODO: Why is this necessary?

  // Add the series
  seriesNumber = 0;
  foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables)
  if (v.IsDoubleVariable)
  DoubleVariable dv = v.AsDoubleVariable;
  if (dv.Data.Length > chart.Data.Points)
  chart.Data.Points = dv.Data.Length;
  for (int i = 0; i < dv.Data.Length; i++)
  chart.Data[seriesNumber, i] = dv.Data;
  chart.LegendBox.Visible = false;
-- End of Listing 2 --

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...