Profile Picture

How to get Chart Bounds?

Posted By Ilia Yatsenko 14 Years Ago
Author
Message
Ilia Yatsenko
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
Yes! It works Thanks a lot.

bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Ilia,

I see - this is kind of tricky to accompish. The idea is to dock a content panel to the chart plot area and get this panel bounds. The following code shows how to  do it:

private void Form1_Load(object sender, EventArgs e)
{
  NChart chart = nChartControl1.Charts[0];

  NBarSeries bar = new NBarSeries();
  bar.Values.Add(10);
  bar.Values.Add(20);
  bar.Values.Add(30);
  chart.Series.Add(bar);

  chart.PositionChildPanelsInContentBounds = true;

  NWatermark panel = new NWatermark();

  panel.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White));
  panel.StandardFrameStyle.Visible = false;
  panel.Dock = DockStyle.Fill;
  panel.PaintCallback = new NMyPaintCallback();

  chart.ChildPanels.Add(panel);
}

class NMyPaintCallback : NPaintCallback
{
  public NMyPaintCallback()
  {
  }

  public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
  {
    NContentPanel contentPanel = (NContentPanel)panel;
    eventArgs.Graphics.PaintRectangle(
    new NColorFillStyle(Color.FromArgb(35, Color.Red)),
    null,
    contentPanel.ContentBounds);
  }
}

Are these the intended bounds?

Best regards,
Bob

 

 



Ilia Yatsenko
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
this bounds size is same as ContentBounds, ContentArea.Bounds or MarginsArea. I need a way to get chart only size, wihtout axes and labels.
may be somehow I can get axis width? I will substract axis width from chart bounds width and get size I need

bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Ilia,

You can get the chart bounds by installing a paint callback:

private void Form1_Load(object sender, EventArgs e)
{
this.nChartControl1.Charts[0].PaintCallback = new NMyPaintCallback();
}

class NMyPaintCallback : NPaintCallback
{
public NMyPaintCallback()
{
}

public override void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
{
NChart chart = (NChart)panel;
Debug.WriteLine(chart.Bounds.ToString());
}
}

This is necessary because the chart bounds are valid only after the control has been recalculated.

Hope this helps - let me know if you meet any problems.

Best regards,
Bob



Ilia Yatsenko
questionmark Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
Hi there!

I can't find an option how to get chart bounds. I want make candlestick width and space between constant when I resize chart.

Can you suggest something?

Update: I attached image to show issue. Please help.

http://i47.tinypic.com/28sxwrl.jpg



Similar Topics


Reading This Topic