Can I format text in tooltips / render my own tooltip?


Author
Message
Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K
Hi

We have a new requirement to create formatted tooltips rather than simple multi-line unformatted text.
Is this possible? It looks like the current tooltip can only be plain text.

Can I hook into a Mouse Hover event somehow and render my own tooltip with formatted text, configurable borders, drop shadow, background colour etc.?

Thanks
Kevin

Replies
Eli Gazit
Eli Gazit
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
Posts: 3, Visits: 5
Hi,
I am trying to do a similar thing - show HTML tooltip instead of plain text.
I could not understand from your sample above how to obtain the user-control that hosts the tooltip and replace it with my own control.
please advise.


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 Eli,
The following code shows how to override the standard tooltip tool so that it shows a formatted label dynamically. In the next version we'll extend the control to support this as a build in feature:
using Nevron.Chart;
using Nevron.Chart.Windows;
using Nevron.Chart.WinForm;
using Nevron.GraphicsCore;
using System;
using System.Drawing;
using System.Windows.Forms;

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

[Serializable]
class NCustomTooltipTool : NTooltipTool
{
public NCustomTooltipTool(NChartControl chartControl)
{
m_ChartControl = chartControl;

m_TimerHide = new Timer();
m_TimerHide.Tick += OnTimerHideTick;
m_TimerHide.Interval = 2000;

m_TimerShow = new Timer();
m_TimerShow.Tick += OnTimerShowTick;
m_TimerShow.Interval = 1000;
}

private void OnTimerHideTick(object sender, EventArgs e)
{
m_TimerHide.Stop();
ClearTooltip();
}

private void OnTimerShowTick(object sender, EventArgs e)
{
if (m_Label == null)
{
m_Label = new NLabel();
m_Label.TextStyle.TextFormat = TextFormat.XML;
m_Label.UseAutomaticSize = true;
m_ChartControl.Panels.Add(m_Label);
}

m_Label.Text = m_RequestTooltip;
m_PrevShownTooltip = m_RequestTooltip;
m_Label.Location = new NPointL(new NLength((int)m_MousePosition.X, NGraphicsUnit.Pixel), new NLength((int)m_MousePosition.Y, NGraphicsUnit.Pixel));
m_ChartControl.Refresh();
m_TimerHide.Start();
}

protected override void SetTooltip(NPointF mousePosition, string tooltip)
{
if (m_PrevShownTooltip == tooltip)
{
return;
}

if (m_RequestTooltip == tooltip)
{
m_TimerShow.Stop();
m_TimerShow.Start();
m_MousePosition = mousePosition;
return;
}

m_RequestTooltip = tooltip;
}

protected override void ClearTooltip()
{
if (m_Label != null)
{
m_TimerShow.Stop();

m_Label.ParentPanel.ChildPanels.Remove(m_Label);
m_Label = null;
m_ChartControl.Refresh();
}
}

NChartControl m_ChartControl;
NLabel m_Label;
Timer m_TimerShow;
Timer m_TimerHide;
string m_PrevShownTooltip;
string m_RequestTooltip;
NPointF m_MousePosition;
}

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

bar.Values.Add(10);
bar.InteractivityStyles.Add(0, new NInteractivityStyle("Bar <b>1</b>"));
bar.Values.Add(20);
bar.InteractivityStyles.Add(1, new NInteractivityStyle("Bar <b>2</b>"));
bar.Values.Add(30);
bar.InteractivityStyles.Add(2, new NInteractivityStyle("Bar <b>3</b>"));

chart.Series.Add(bar);

nChartControl1.Controller.Tools.Add(new NCustomTooltipTool(nChartControl1));
}
}
}
Hope this helps - let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team


Eli Gazit
Eli Gazit
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
Posts: 3, Visits: 5
Hello, any news?
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
Hello Eli,
We still haven't released the new version. This will most likely happen at the end of August...

Best Regards,
Nevron Support Team


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