Hi Fabio,
The tooltip issue has been fixed in the latest SP (16.5.31.12) and you should receive a download link from support when it's uploaded. In this SP we have also extended the tooltip tool so that you can override what happens when a tooltip is shown / hidden. The following code shows how to implement a tooltip with dynamically changing border depending on the underlying line series stroke:
using Nevron;
using Nevron.Chart;
using Nevron.Chart.Windows;
using Nevron.Dom;
using Nevron.GraphicsCore;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace SmallNevronProject
{
/// <summary>
/// Interaction logic for Mainwindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private NAxis _xAxis;
private NAxis _yAxis;
private NCartesianChart _chart;
class MyTooltipTool : NTooltipTool
{
public MyTooltipTool(Nevron.Chart.Wpf.NChartControl chartControl)
{
m_ChartControl = chartControl;
}
protected override void SetTooltip(NPointF mousePosition, string tooltip)
{
if (tooltip == null || tooltip.Length == 0)
{
ClearTooltip();
return;
}
NHitTestResult hitTestResult = m_ChartControl.HitTest((int)mousePosition.X, (int)mousePosition.Y);
if (tooltip != m_Tooltip)
{
ClearTooltip();
m_Tooltip = tooltip;
}
System.Windows.Controls.ToolTip tooltipControl = m_ChartControl.ToolTip as System.Windows.Controls.ToolTip;
if (tooltipControl == null)
{
tooltipControl = new System.Windows.Controls.ToolTip();
m_ChartControl.ToolTip = tooltipControl;
tooltipControl.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse;
}
if (hitTestResult.ChartElement == ChartElement.DataPoint)
{
NLineSeries lineSeries = hitTestResult.Series as NLineSeries;
if (lineSeries != null)
{
System.Drawing.Color color = lineSeries.BorderStyle.Color;
tooltipControl.BorderBrush = new SolidColorBrush(Color.FromRgb(color.R, color.G, color.B));
tooltipControl.BorderThickness = new Thickness(2);
}
}
if (tooltipControl.Content != tooltip)
{
tooltipControl.Content = tooltip;
tooltipControl.IsOpen = true;
}
}
protected override void ClearTooltip()
{
System.Windows.Controls.ToolTip tooltipControl = m_ChartControl.ToolTip as System.Windows.Controls.ToolTip;
if (tooltipControl != null)
{
tooltipControl.IsOpen = false;
}
}
Nevron.Chart.Wpf.NChartControl m_ChartControl;
string m_Tooltip;
}
public MainWindow()
{
InitializeComponent();
_chart = new NCartesianChart();
Plot.Charts.Clear();
Plot.Charts.Add(_chart);
Plot.BackgroundStyle.FrameStyle.Visible = false;
_chart.RangeSelections.Add(new NRangeSelection());
_chart.LabelLayout.EnableInitialPositioning = true;
_chart.LabelLayout.EnableLabelAdjustment = true;
_chart.BoundsMode = BoundsMode.Stretch;
_chart.DockMode = PanelDockMode.Fill;
_yAxis = _chart.Axis(StandardAxis.PrimaryY);
_xAxis = _chart.Axis(StandardAxis.PrimaryX);
var scale = new NLinearScaleConfigurator();
scale.RoundToTickMax = false;
scale.MinorGridStyle.SetShowAtWall(ChartWallType.Back, true);
scale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
scale.MinorTickCount = 4;
_yAxis.ScaleConfigurator = scale;
var timeLineScale = new NDateTimeScaleConfigurator();
timeLineScale.RoundToTickMax = false;
timeLineScale.RoundToTickMin = false;
timeLineScale.MinorGridStyle.SetShowAtWall(ChartWallType.Back, false);
timeLineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
timeLineScale.MajorTickMode = MajorTickMode.AutoMaxCount;
timeLineScale.LabelValueFormatter = new NDateTimeValueFormatter("mm/yyyy");
timeLineScale.EnableUnitSensitiveFormatting = false;
timeLineScale.MaxTickCount = 6;
timeLineScale.MinorTickCount = 1;
timeLineScale.AutoDateTimeUnits = new NDateTimeUnit[] { NDateTimeUnit.Day, NDateTimeUnit.Month, NDateTimeUnit.Year, };
timeLineScale.MajorTickMode = MajorTickMode.AutoMaxCount;
timeLineScale.MaxTickCount = 6;
timeLineScale.DateTimeUnitFormatterPairs.MonthFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.MonthShortName);
timeLineScale.DateTimeUnitFormatterPairs.YearFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Year4Digit);
_xAxis.ScaleConfigurator = timeLineScale;
var selector = new NSelectorTool();
selector.Focus = true; // make sure the control gets focus when mouse down occurs
Plot.Controller.Tools.Add(selector);
var dzt = new NDataZoomTool();
dzt.WheelZoomAtMouse = true;
dzt.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, Nevron.Chart.Windows.MouseButton.None, 0);
var ttl = new NTooltipTool();
ttl.InitialDelay = 0;
ttl.AutoPopDelay = -1;
Plot.Controller.Tools.Add(dzt);
Plot.Controller.Tools.Add(new MyTooltipTool(Plot));
Plot.Controller.Tools.Add(new NDataPanTool());
NSeries newSeries;
newSeries = new NLineSeries() { Name = "aa" };
var timeList = new List<DateTime>
{
new DateTime(1999, 5, 2), new DateTime(2000, 5, 3), new DateTime(2001,6,4),
new DateTime(2002, 2, 3), new DateTime(2003, 4, 3)
};
var valuesList = new List<float> {2, -1, 3, -4, 5};
(newSeries as NLineSeries).XValues.AddRange(timeList);
(newSeries as NLineSeries).XValues.ValueFormatter = new NDateTimeValueFormatter("mm/yyyy");
(newSeries as NLineSeries).UseXValues = true;
newSeries.Values.AddRange(valuesList);
newSeries.Values.ValueFormatter = new NNumericValueFormatter("0.000");
newSeries.InteractivityStyle.Tooltip.Text = "Y: <value>" + '\n' + "X: <xvalue>";
newSeries.BorderStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
newSeries.BorderStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
newSeries.BorderStyle.Width = new NLength(3);
newSeries.InflateMargins = true;
newSeries.DataLabelStyle.Visible = false;
_chart.Series.Add(newSeries);
Plot.Refresh();
}
}
}
Hope this helps - let us know if you meet any problems or have any questions.
Best Regards,
Nevron Support Team