User (Legacy) Posted July 31, 2006 Report Share Posted July 31, 2006 In using font markers on my chart, the rendering of the markers is offseting them slightly up and to the left. I built a sample chart using the following code that illustrates the problem. When you run this, you can see that the markers are noticably shifted up and to the left. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FontMarkers { public partial class Form1 : Form { public Form1() { InitializeComponent(); chart1.ExtraStyle |= ChartFX.WinForms.ChartStyles.PaintMarker; chart1.AllSeries.MarkerFont = new Font("Wingdings", 10); chart1.AllSeries.MarkerSize = (short)(chart1.AllSeries.MarkerFont.Size / 2.0); chart1.Series[0].MarkerShape = (ChartFX.WinForms.MarkerShape)(-0x6c); chart1.Series[1].MarkerShape = (ChartFX.WinForms.MarkerShape)(-0x6e); chart1.Series[2].MarkerShape = (ChartFX.WinForms.MarkerShape)(-0x75); } // Draws a crosshair where the marker should be centered. private void chart1_PaintMarker(object sender, ChartFX.WinForms.PaintMarkerEventArgs e) { int c = (2 * chart1.AllSeries.MarkerSize) + 4; int r = c / 2; int x = e.Position.X; int y = e.Position.Y; e.Graphics.DrawLine(Pens.Black, x - r, y, x + r, y); e.Graphics.DrawLine(Pens.Black, x, y - r, x, y + r); int ll = x - r; int tt = y - r; e.Graphics.DrawEllipse(Pens.Black, ll, tt, c, c); } } } Link to comment Share on other sites More sharing options...
Software FX Posted July 31, 2006 Report Share Posted July 31, 2006 The character is being draw using StringAlignment.Center for both Alignment and Line Alignment. For some reason Windows/GDI+ is deciding that is the center. You can verify this in your chart1_PaintMarker method. You will need to either chose a symbol that is centered or paint the marker yourself in the chart1_PaintMarker method. -- Francisco Padron www.chartfx.com Link to comment Share on other sites More sharing options...
User (Legacy) Posted August 1, 2006 Author Report Share Posted August 1, 2006 Ok, I'm heading down the path of using PaintMarker to draw the marker myself, but I've run into a problem with the markers now being drawn twice. The following code will result in my marker (a black crosshair) being drawn as expected, but the cfx marker is also still being drawn. I set e.Handled to true in PaintMarker, but that had absolutely no effect. So I also set e.Handled = true in PrePaintMarker. But, this only caused the line to be suppressed (which I don't want!), and the cfx markers are still drawn. Interestingly enough, if I change the gallery to Gallery.Scatter, the e.Handled = true in PrePaintMarker suppresses the cfx marker as expected. What am I missing? public partial class Form1 : Form { public Form1() { InitializeComponent(); chart1.Gallery = ChartFX.WinForms.Gallery.Lines; chart1.ExtraStyle |= ChartFX.WinForms.ChartStyles.PaintMarker; } // Draws a crosshair where the marker should be centered. private void chart1_PaintMarker(object sender, ChartFX.WinForms.PaintMarkerEventArgs e) { int c = (2 * chart1.AllSeries.MarkerSize) + 4; int r = c / 2; int x = e.Position.X; int y = e.Position.Y; e.Graphics.DrawLine(Pens.Black, x - r, y, x + r, y); e.Graphics.DrawLine(Pens.Black, x, y - r, x, y + r); int ll = x - r; int tt = y - r; e.Graphics.DrawEllipse(Pens.Black, ll, tt, c, c); e.Handled = true; } private void chart1_PrePaintMarker(object sender, ChartFX.WinForms.PaintMarkerEventArgs e) { e.Handled = true; } } Link to comment Share on other sites More sharing options...
Software FX Posted August 4, 2006 Report Share Posted August 4, 2006 You won't be able to stop just the marker from drawing using e.Handled. As a matter of fact e.Handled = true should have prevented BOTH the marker and the line from being drawn. What I suggest is that you set the MarkerSize to 0, this will eliminate the marker from the chart while keeping it in the legend box and other places. -- Francisco Padron www.chartfx.com Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.