I have two custom tool tips that I use to display data about the series that’s being hovered. The only problem is that the graph seems to only use 1 tooltip no matter what.
I have set each series to use their own tooltip or null when I create them but in practice the graph will only display what its global setting is set too.
When I debug I can see that each series still has it’s own custom tooltip set so it’s not like the series themselves are changing.
Any kind of help would be appreciated!
Using Livecharts 0.9.7.1 for winforms.
Code:
This is how i make a line series
LineSeries line = new LineSeries
{
Title = "Minimum Stock Level",
Values = chartValues, // The chart values to plot
Stroke = new SolidColorBrush(Colors.DarkOrange),
StrokeThickness = 2,
Fill = Brushes.Transparent,
LineSmoothness = 0,
PointGeometrySize = 0,
StrokeDashArray = new DoubleCollection { 2 },
Tag = stockDataPoints,
ToolTip = new CustomTooltip() { SelectionMode = TooltipSelectionMode.OnlySender }
};
This is an example of how I update the series on my graphs:
private async void UpdateGlassStockGraph()
{
// Clear existing series
chartGlassStock.Series.Clear();
// Get new series data
SeriesCollection projectSeries = await chartGen.GetProjectSeriesAsync(null, new StockItem(Code, ""), false);
foreach (var series in projectSeries)
{
chartGlassStock.Series.Add(series);
}
// Ensure the chart update runs on the UI thread
if (chartGlassStock.IsHandleCreated)
{
chartGlassStock.BeginInvoke((Action)(() =>
{
chartGlassStock.Update(); // Update the chart
}));
}
}
When i load the form i set:
chartStock.DataTooltip = null;
But this overrides any of the series DataTooltips
This is basically taken straight from the tutorial page:
public partial class CustomTooltip : IChartTooltip
{
private TooltipData _data;
public CustomTooltip()
{
InitializeComponent();
//LiveCharts will inject the tooltip data in the Data property
//your job is only to display this data as required
DataContext = this;
}
public event PropertyChangedEventHandler PropertyChanged;
public TooltipData Data
{
get { return _data; }
set
{
_data = value;
OnPropertyChanged("Data");
}
}
public TooltipSelectionMode? SelectionMode { get; set; }
protected virtual void OnPropertyChanged(string propertyName = null)
{
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}