I am on LightningChart version 8.3.1, and I have tried to get a bindable IntensityMeshSeries working based on the bindable example for the IntensityGridSeries, however, I have been unable to do so at this time.
In my project, I have several sets of static data that I need to display. If I set breakpoints, I can see that the data is properly bound to the IntensityMeshSeries.Data member; however, nothing displays.
I modified the code for the bindable IntensityGridSeries sample project ExampleHiResSepctrogram to closely mimic what I need to do; however, nothing displays.
What am I missing?
My modifications are below.
Thank you.
Code: Select all
<Window x:Class="ExampleHiResSpectrogram.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lcub="http://schemas.arction.com/bindablecharting/ultimate/"
xmlns:viewModels="clr-namespace:ViewModels;assembly=ViewModels"
Tag="[XY View Examples\Real-Time][2d;xy;cartesian;real-time;realtime;spectrum;intensity;heatmap;spectrogram;scrolling;waterfall]"
Title="High-Resolution Spectrogram" Height="350" Width="525">
<Window.DataContext>
<viewModels:ExampleHiResSpectrogramViewModel/>
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<lcub:LightningChartUltimate ChartName="Spectrogram Chart">
<lcub:LightningChartUltimate.ViewXY>
<lcub:ViewXY>
<lcub:ViewXY.XAxes>
<lcub:AxisX ScrollMode="None" ValueType="Number" Maximum="10" Minimum="0">
<lcub:AxisX.Title>
<lcub:AxisXTitle Text="Frequency (Hz)"/>
</lcub:AxisX.Title>
</lcub:AxisX>
</lcub:ViewXY.XAxes>
<lcub:ViewXY.YAxes>
<lcub:AxisY Minimum="0" Maximum="10">
<lcub:AxisY.Title>
<lcub:AxisYTitle Text="Time"/>
</lcub:AxisY.Title>
</lcub:AxisY>
</lcub:ViewXY.YAxes>
<lcub:ViewXY.AxisLayout>
<lcub:AxisLayout AutoAdjustMargins="False"/>
</lcub:ViewXY.AxisLayout>
<lcub:ViewXY.LegendBoxes>
<lcub:LegendBoxXY Layout="Vertical" UnitsColor="Transparent"/>
</lcub:ViewXY.LegendBoxes>
<lcub:ViewXY.ZoomPanOptions>
<lcub:ZoomPanOptions LeftMouseButtonAction="None" RightMouseButtonAction="None" MouseWheelZooming="Off"/>
</lcub:ViewXY.ZoomPanOptions>
<lcub:ViewXY.IntensityMeshSeries>
<lcub:IntensityMeshSeries
ContourLineType="None"
Fill="Paletted"
WireframeType="None"
MouseInteraction="False"
Data="{Binding Points}"
ToneColor="Green">
<lcub:IntensityMeshSeries.Title>
<lcub:SeriesTitle Text="P(f)"/>
</lcub:IntensityMeshSeries.Title>
<lcub:IntensityMeshSeries.ValueRangePalette>
<lcub:ValueRangePalette Type="Gradient" MinValue="0">
<lcub:ValueRangePalette.Steps>
<lcub:PaletteStep Color="Black" MaxValue="0"/>
<lcub:PaletteStep Color="Yellow" MaxValue="50"/>
<lcub:PaletteStep Color="Red" MaxValue="100"/>
</lcub:ValueRangePalette.Steps>
</lcub:ValueRangePalette>
</lcub:IntensityMeshSeries.ValueRangePalette>
</lcub:IntensityMeshSeries>
</lcub:ViewXY.IntensityMeshSeries>
</lcub:ViewXY>
</lcub:LightningChartUltimate.ViewXY>
</lcub:LightningChartUltimate>
<Grid Grid.Column="1">
<StackPanel Margin="8">
<Label>Spectrum resolution</Label>
<TextBox Text="{Binding SpectrumResolution}"/>
<Label>History length</Label>
<TextBox Text="{Binding HistoryLength}"/>
<Button Command="{Binding RestartCommand}">Restart</Button>
</StackPanel>
</Grid>
</Grid>
</Window>
Code: Select all
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Arction.Wpf.BindableCharting.SeriesXY;
namespace ViewModels
{
public partial class ExampleHiResSpectrogramViewModel
{
private DelegateCommand _restartCommand = null;
private ExampleHiResSpectrogramModel _model = null;
bool dataGenerated = false;
public ExampleHiResSpectrogramViewModel()
{
_restartCommand = new DelegateCommand(RestartMethod);
_model = new ExampleHiResSpectrogramModel();
_model.DataGenerated += _model_DataGenerated;
Points = new IntensityPointMatrix();
Points.ColumnsRowsOrder = IntensityPointMatrix.ColsRowsOrder.RowsColumns;
HistoryLength = 100;
IntensityGridMaxX = 12000.0;
IntensityGridMaxY = 0.0;
IntensityGridMinX = 0.0;
IntensityGridMinY = -10.0;
SpectrumResolution = 1000;
YMaximum = 0.0;
YMinimum = -10.0;
}
public ICommand RestartCommand
{
get { return _restartCommand; }
}
private void RestartMethod(Object obj)
{
_model.Restart();
}
private void _model_DataGenerated(object sender, DataGeneratedEventArgs args)
{
int iRowCount = args.Data.Length;
int iColCount = args.Data[0].Length;
IntensityPointCollection[] collections = new IntensityPointCollection[iRowCount];
//for (int i = 0; i < iRowCount; i++)
//{
// IntensityPoint[] pointsArray = new IntensityPoint[iColCount];
// for (int j = 0; j < iColCount; j++)
// {
// double value = args.Data[i][j];
// IntensityPoint ip = new IntensityPoint((double)j, (double)i, value, Colors.Green);
// if (value < 33)
// {
// // Black color for values less than 33.
// ip.Color = Colors.Black;
// }
// else if (value < 66)
// {
// // Yellow color for values between 33 and 65.999...
// ip.Color = Colors.Yellow;
// }
// else
// {
// // Red color for values over 66.
// ip.Color = Colors.Red;
// }
// ip.Value = value;
// pointsArray[j] = ip;
// }
// IntensityPointCollection ipc = new IntensityPointCollection();
// ipc.AddRange(pointsArray);
// collections[i] = ipc;
//}
if (dataGenerated == false)
{
IntensityPointCollection collection = new IntensityPointCollection();
for (double x = 0; x < 10; x += 0.1)
{
for (double y = 0; y < 10; y += 0.1)
{
IntensityPoint pt = new IntensityPoint();
pt.X = x;
pt.Y = y;
pt.Value = x * y;
if(pt.Value < 33)
{
pt.Color = Colors.Black;
}
else if (pt.Value < 66)
{
pt.Color = Colors.Yellow;
}
else
{
pt.Color = Colors.Red;
}
collection.Add(pt);
}
}
Points.Clear();
Points.Add(collection);
dataGenerated = true;
}
//int newCount = Points.Count + collections.Length;
//if (newCount <= HistoryLength)
//{
// Points.AddRange(collections);
//}
//else
//{
// Points.AddRange(collections, true);
//}
//double dCurrentYMin = YMinimum;
//double dYShift = (double)iRowCount * (10.0 / HistoryLength);
//YMinimum = dCurrentYMin + dYShift;
//YMaximum = dCurrentYMin + dYShift + 10.0;
//IntensityGridMaxX = 12000.0;
//IntensityGridMaxY = YMaximum;
//IntensityGridMinX = 0.0;
//IntensityGridMinY = YMinimum;
}
}
public partial class ExampleHiResSpectrogramViewModel : RealtimeExampleViewModel
{
public static readonly DependencyProperty HistoryLengthProperty =
DependencyProperty.Register(
"HistoryLength",
typeof(int),
typeof(ExampleHiResSpectrogramViewModel),
new PropertyMetadata(new PropertyChangedCallback(HistoryLengthChanged))
);
public static readonly DependencyProperty IntensityGridMaxXProperty =
DependencyProperty.Register(
"IntensityGridMaxX",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty IntensityGridMaxYProperty =
DependencyProperty.Register(
"IntensityGridMaxY",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty IntensityGridMinXProperty =
DependencyProperty.Register(
"IntensityGridMinX",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty IntensityGridMinYProperty =
DependencyProperty.Register(
"IntensityGridMinY",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty PointsProperty =
DependencyProperty.Register(
"Points",
typeof(IntensityPointMatrix),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty SpectrumResolutionProperty =
DependencyProperty.Register(
"SpectrumResolution",
typeof(int),
typeof(ExampleHiResSpectrogramViewModel),
new PropertyMetadata(new PropertyChangedCallback(SpectrumResolutionChanged))
);
public static readonly DependencyProperty YMaximumProperty =
DependencyProperty.Register(
"YMaximum",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
public static readonly DependencyProperty YMinimumProperty =
DependencyProperty.Register(
"YMinimum",
typeof(double),
typeof(ExampleHiResSpectrogramViewModel)
);
private static void HistoryLengthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ExampleHiResSpectrogramViewModel vm = d as ExampleHiResSpectrogramViewModel;
if (vm != null)
{
vm._model.HistoryLength = (int)e.NewValue;
}
}
private static void SpectrumResolutionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ExampleHiResSpectrogramViewModel vm = d as ExampleHiResSpectrogramViewModel;
if (vm != null)
{
vm._model.SpectrumResolution = (int)e.NewValue;
}
}
public int HistoryLength
{
get { return (int)GetValue(HistoryLengthProperty); }
set { SetValue(HistoryLengthProperty, (int)value); }
}
public double IntensityGridMaxX
{
get { return (double)GetValue(IntensityGridMaxXProperty); }
set { SetValue(IntensityGridMaxXProperty, (double)value); }
}
public double IntensityGridMaxY
{
get { return (double)GetValue(IntensityGridMaxYProperty); }
set { SetValue(IntensityGridMaxYProperty, (double)value); }
}
public double IntensityGridMinX
{
get { return (double)GetValue(IntensityGridMinXProperty); }
set { SetValue(IntensityGridMinXProperty, (double)value); }
}
public double IntensityGridMinY
{
get { return (double)GetValue(IntensityGridMinYProperty); }
set { SetValue(IntensityGridMinYProperty, (double)value); }
}
public IntensityPointMatrix Points
{
get { return GetValue(PointsProperty) as IntensityPointMatrix; }
set { SetValue(PointsProperty, value as Object); }
}
public int SpectrumResolution
{
get { return (int)GetValue(SpectrumResolutionProperty); }
set { SetValue(SpectrumResolutionProperty, (int)value); }
}
public double YMaximum
{
get { return (double)GetValue(YMaximumProperty); }
set { SetValue(YMaximumProperty, (double)value); }
}
public double YMinimum
{
get { return (double)GetValue(YMinimumProperty); }
set { SetValue(YMinimumProperty, (double)value); }
}
public override bool IsRunning
{
get { return _model.IsRunning; }
}
public override void Start()
{
if (IsRunning == false)
{
_model.Restart();
}
}
public override void Stop()
{
if (IsRunning == true)
{
_model.Stop();
base.RaiseStoppedEvent();
}
}
}
}