Profile Picture

Using HitTest to interact with NRectangularCallout

Posted By Kasper Juul Larsen 6 Years Ago
Author
Message
Kasper Juul Larsen
Problem Posted 6 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 3, Visits: 5
Hello,
Is there a way to use HitTest to interact with callouts (NRectangularCallout)?

The idea is to create and display callouts when clicking on line series, and const lines in my chart. Then if the user clicks inside the callout I would like to close it again. 

Best regards
Kasper

Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Kasper,
Yes you can detect that the user clicked on a callout - the following sample shows how to use the Object property of the NHitTestResult object to achieve that:
using Nevron.Chart;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

NRectangularCallout m_Callout;
NChart m_Chart;

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

NLineSeries line = new NLineSeries();

for (int i = 0; i < 10; i++)
{
line.Values.Add(i);
}

m_Chart.Series.Add(line);

m_Callout = new NRectangularCallout();
m_Callout.Text = "Some Text";
m_Callout.UseAutomaticSize = true;
m_Callout.Anchor = new NDataPointAnchor(line, 1, ContentAlignment.MiddleCenter, StringAlignment.Center);
m_Chart.ChildPanels.Add(m_Callout);

nChartControl1.MouseDown += NChartControl1_MouseDown;
}

private void NChartControl1_MouseDown(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(new Point(e.X, e.Y));
if (m_Callout == result.Object)
{
m_Chart.ChildPanels.Remove(m_Callout);
m_Callout = null;
nChartControl1.Refresh();
}
}
}
}
Hope this helps - let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic