Hi guys,
I’ve been trying to select data points in my heat map for the whole without success. I’ve read, re-read and re-re-read the documentation, but I can’t figure out what I’m doing wrong.
Here’s the XAML.
...
<s:SciChartSurface.RenderableSeries>
<s:FastUniformHeatmapRenderableSeriesForMvvm
x:Name="heatmapSeries"
Opacity="0.9"
DataSeries="{Binding UniformHeatmapDataSeries}"
s:DataPointSelectionModifier.IncludeSeries="True" >
<s:FastUniformHeatmapRenderableSeriesForMvvm.ColorMap>
<s:HeatmapColorPalette Maximum="60" Minimum="6">
<s:HeatmapColorPalette.GradientStops>
<GradientStop Offset="0" Color="Transparent"/>
<GradientStop Offset="0.1" Color="DarkBlue"/>
<GradientStop Offset="0.2" Color="CornflowerBlue"/>
<GradientStop Offset="0.4" Color="DarkGreen"/>
<GradientStop Offset="0.6" Color="Chartreuse"/>
<GradientStop Offset="0.8" Color="Yellow"/>
<GradientStop Offset="1" Color="Red"/>
</s:HeatmapColorPalette.GradientStops>
</s:HeatmapColorPalette>
</s:FastUniformHeatmapRenderableSeriesForMvvm.ColorMap>
<s:FastUniformHeatmapRenderableSeriesForMvvm.PointMarker>
<s:XPointMarker Fill="Pink" Width="5" Height="5"/>
</s:FastUniformHeatmapRenderableSeriesForMvvm.PointMarker>
<s:FastUniformHeatmapRenderableSeriesForMvvm.SelectedPointMarker>
<s:TrianglePointMarker Fill="White" Width="12" Height="12"/>
</s:FastUniformHeatmapRenderableSeriesForMvvm.SelectedPointMarker>
</s:FastUniformHeatmapRenderableSeriesForMvvm>
...
</s:SciChartSurface.RenderableSeries>
...
Here’s the MVVM code.
...
class SelectedPointMetadata : IPointMetadata
{
public bool IsSelected { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
...
double[,] heatMap = new double[heatMapHeight + glowRadius * 2, heatMapWidth + glowRadius * 2];
double[,] glowMatrix = this.getGlowEffectMatrix(glowRadius);
SelectedPointMetadata[,] selectablePoints = new SelectedPointMetadata[heatMapHeight + glowRadius * 2, heatMapWidth + glowRadius * 2];
for (int i = 0; i < spectrogram.SpectrogramAtoms.Count; i++) {
var atom = spectrogram.SpectrogramAtoms[i];
int x = Math.Min((int)(atom.Frequency.Hertz / frequencyStep) + glowRadius, heatMapHeight - 1);
int y = Math.Min((int)(atom.Time.Seconds / xStep) + glowRadius, heatMapWidth - 1);
this.applyEffectMatrix(x, y, atom.SNR, ref heatMap, ref glowMatrix, glowRadius);
}
var xBound = heatMap.GetLength(0);
var yBound = heatMap.GetLength(1);
Random rnd = new Random();
for (var i = 0; i < xBound; i++)
{
for (var j = 0; j < yBound; j++)
{
var x = rnd.Next(1, 10);
selectablePoints[i, j] = new SelectedPointMetadata() { IsSelected = false };
if (x == 5)
{
selectablePoints[i, j].IsSelected = true;
}
}
}
this.UniformHeatmapDataSeries = new UniformHeatmapDataSeries<double, double, double>(
heatMap,
(-xStep * glowRadius),
xStep,
(-frequencyStep * glowRadius),
frequencyStep,
selectablePoints
);
...
What am I missing?
- Nicolas Bourré asked 6 years ago
- You must login to post comments
Hi Nicolas,
Thanks for your question.
You have to create a PaletteProvider that will decide which heatmap cells to change. You can check the SelectedPointMetadata inside it to choose points that have to be selected.
Please take a look at our Uniform Heatmap and Custom Palette Provider example:
https://www.scichart.com/example/wpf-chart-example-uniform-heatmap-custom-palette/
And our documentation regarding Paletted Series:
https://www.scichart.com/documentation/v5.x/webframe.html#Paletted%20Series.html
- Oleksandr Shvets answered 6 years ago
- You must login to post comments
Hi there,
Thanks for your question.
Unfortunately, the behaviour you are looking for is not supported by SciChart out of the box.
Our heatmap dataseries metadata has a different format, so the behaviour of selecting data points from its metadata is a bit complicated, and it is not implemented in the current version.
You may submit this as a feature request. To see how to submit a feature request and how are they prioritized, please read here:
https://www.scichart.com/feedback-policy/
- Oleksandr Shvets answered 5 years ago
- You must login to post comments
Hello,
I am trying to do something similar, but define the selected data by a mouse drag on the heatmap surface, i.e. with a DataPointSelectionModifier:
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:DataPointSelectionModifier/>
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
After adding this modifier and using my mouse to select a part of the heatmap, I get the following System.InvalidOperationException (stack trace below):
"Metadata for his type cannot be returned as an one-dimentional array. Please use the IPointMetadata[,] Metadata property"
I’m assuming this is happening because DataPointSelectionModifier was by default not meant for data series with 2D arrays, but I’m not sure how to follow the exception message “Please use the IPointMetadata[,] Metadata property”. Any help would be appreciated.
Stack trace:
at SciChart.Charting.Model.DataSeries.Heatmap2DArrayDataSeries.BaseHeatmapDataSeries`3.SciChart.Charting.Model.DataSeries.IDataSeries.get_Metadata()
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.UpdateState()
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.KUB()
at A.MEB.D[D](D D, Boolean I, Func`1 J)
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.get_SelectedPointMarkers()
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.DeselectAllPointMarkers()
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.SelectManyPoints(Point startPoint, Point endPoint, SelectionMode selectionMode)
at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.OnModifierMouseUp(ModifierMouseArgs e)
at SciChart.Charting.ChartModifiers.ModifierGroup.FTB(Action`2 D, ModifierEventArgsBase I)
at SciChart.Core.Extensions.EnumerableExtensions.ForEachDo[T](IEnumerable`1 enumerable, Action`1 operation)
at SciChart.Core.Utility.Mouse.MouseManager.GB(IPublishMouseEvents D, IReceiveMouseEvents I, MouseEventArgs J, MouseButtons M, Action`3 O)
at SciChart.Core.Utility.Mouse.MouseManager.AEB.S(Object D, MouseButtonEventArgs I)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at Main.main(String[] _arg1) in ...\App.fs:line 13
- jsacks answered 5 years ago
- last edited 5 years ago
- You must login to post comments
Please login first to submit.