size/bottom left coordinate of graph


Author
Message
Daniel Csimszi
Daniel Csimszi
Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)
Group: Forum Members
Posts: 61, Visits: 35
Hi,

Should have waited 5 min before my last port. Previously I been have advised that I can for the graph to recalculate itself, using that it seems to be working, it is not perfect but the best what I could do just now, so it might just do. This is the code:

private void nChartControl1_SizeChanged(object sender, EventArgs e)
{
nChartControl1.Document.Calculate();
nChartControl1.Document.RecalcLayout(nChartControl1.View.Context);

NPointF p = nChartControl1.Charts[0].PlotArea.LeftBottom;
Console.WriteLine("Chart X: " + p.X + "Chart Y: " + p.Y);
panel2.Location = new Point(Convert.ToInt32(p.X), Convert.ToInt32(p.Y));
}

Thank you for your help
Daniel
Daniel Csimszi
Daniel Csimszi
Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)
Group: Forum Members
Posts: 61, Visits: 35
Hi,

Thank you for your answer, and sorry for the late reply.

I tried your method, it is almost working. I can not really use it just when the graph is recalculated as my graph refreshes in every 3 second. So if the user re size the screen the objects will not move for a maximum of 3 seconds. I tried to put the method in the re size event the way like that:

private void nChartControl1_SizeChanged(object sender, EventArgs e)
{
NPointF p = nChartControl1.Charts[0].PlotArea.LeftBottom;
Console.WriteLine("Chart X: " + p.X + "Chart Y: " + p.Y);
panel2.Location = new Point(Convert.ToInt32(p.X), Convert.ToInt32(p.Y));
}

Unfortunately that does not work nether, as it seems it is using the size of the graph before re size. Do you know what could be the solution the get the coordinates after the re size?

Thanks a lot
Daniel
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Daniel,

You can use the chart's PlotArea property, but please note that it is valid only after the chart is calculated - for example in the paint callback notification methods. The following code draws a red circle on top of the Bottom-Left corner of the chart:


   public partial class Form1 : Form, INPaintCallback
   {
      public Form1()
      {
         InitializeComponent();
      }

      private void Form1_Load(object sender, EventArgs e)
      {
         NChart chart = nChartControl1.Charts[0];
         NBarSeries bar = new NBarSeries();
         chart.Series.Add(bar);
         bar.Values.AddRange(new double[]{ 10, 20, 15 });

         chart.PaintCallback = this;
      }

      public void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
      {
         NPointF p = nChartControl1.Charts[0].PlotArea.LeftBottom;
         eventArgs.Graphics.PaintEllipse(new NColorFillStyle(Color.Red), null, new NRectangleF(p.X - 6, p.Y - 6, 12, 12));
      }
      public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
      {         
      }
   }




Best Regards,
Nevron Support Team


Daniel Csimszi
Daniel Csimszi
Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)
Group: Forum Members
Posts: 61, Visits: 35
Hi,

I need to insert extra graphical objects on my graph. To make it look nice I need to know the coordinate of the bottom left corner. Could you please tell me how can I retrieve that data? Is it possible to know size of the graph?
My graph is set to Dock: Fill so it re-sizes, that is why I need to know the proper size/coordinates of the graph.

Please find attached a picture explaining the situation.

Thank you for your help in advanced
Daniel
Attachments
coordinate.png (164 views, 8.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search