What is best way to change series data from ViewModel?
I modified source code from this topic. Because, It is very beautiful sample.
viewtopic.php?f=16&t=196&hilit=Parallel ... 3D%26gt%3B
I like to use these.
-data binding
-XAML designer
-Semi-Bindable Chart
The Executed result has not changed, but the speed is a bit slow (Within tolerance).
Full Code is attached.
Part is here.
MainWindow.xaml (part)
Code: Select all
<lcusb:ViewXY.IntensityGridSeries>
<lcusb:IntensityGridSeries
x:Name="m_heatmap"
Data="{Binding IntensityPoints}"
...
/>
</lcusb:ViewXY.IntensityGridSeries>
Code: Select all
private void MainWindow_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var vm = (MainWindowViewModel)this.DataContext;
vm.UpdateChartInView = UpdateChart;
//Call VM Method
vm?.StartInVM();
}
//Call from VM
private void UpdateChart()
{
m_chart.BeginUpdate();
m_heatmap.InvalidateValuesDataOnly();
m_chart.EndUpdate();
}
Code: Select all
private IntensityPoint[,] intensityPoints = null;
public IntensityPoint[,] IntensityPoints
{
get { return intensityPoints; }
set
{
intensityPoints = value;
NotifyPropertyChanged();
}
}
public Action UpdateChartInView { get; internal set; }
...
void m_timer_Tick(object sender, EventArgs e)
{
if (m_data == null)
{
//Create a data array
...
IntensityPoints = ConvertIntesityPoint(m_data);
}
//Set new values to data array
for (int iCol = 0; iCol < DataColumnCount; iCol++)
{
for (int iRow = 0; iRow < DataRowCount; iRow++)
{
IntensityPoints[iCol, iRow].Value = (double)m_iRound + 20.0 * Math.Sin((double)iCol * (double)iRow / 5000.0);
}
}
//Call View Method
UpdateChartInView();
...
}
...
This code seems to work fine, but is there any problem?