Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
xamDataChart drawing with IsTransitionInEnabled set to true
posted

Hi there,

i started using xamdatachart with the 2020.1 release.

our final goal is to use it with .NET5, currently this demo targets .NET core 3.1

I have created a simple chart with one series and set IsTransitionInEnabled = True.

Data is being created in the viewmodel.

What i see now when opening the app is, that it starts renedering the series. after maybe a third it resets automatically to the beginning, after that it renders completely.

what could be the reason for this.

Thanks, Thomas

my xaml:

<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ig:XamDataChart Grid.Row="1" x:Name="DataChart"
VerticalZoomable="True" HorizontalZoomable="True" Background="#FFE0DEDE" HorizontalZoombarVisibility="Visible">
<ig:XamDataChart.Axes>
<ig:CategoryXAxis x:Name="xAxis"
ItemsSource="{Binding DataItems}"
Label="{}{X}">
</ig:CategoryXAxis>
<ig:NumericYAxis x:Name="yAxis" Opacity="0">
</ig:NumericYAxis>
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:LineSeries x:Name="Sine" MarkerType="None" Thickness="1"
ItemsSource="{Binding DataItems}"
ValueMemberPath="Y"
Resolution="0.5"
XAxis="{Binding ElementName=xAxis}"
YAxis="{Binding ElementName=yAxis}"
IsTransitionInEnabled="True"/>
</ig:XamDataChart.Series>
</ig:XamDataChart>
</Grid>

my viewmodel

public class MainViewModel : INotifyPropertyChanged
{
public MainViewModel()
{

List<ChartData> lstDataItems = new List<ChartData>();

lstDataItems = GetSineWave(1000, 100, 44100);

dataItems = lstDataItems;
}

private List<ChartData> GetSineWave(double freq, int durationMs, int sampleRate)
{
List<ChartData> lstDataItems = new List<ChartData>();

double sample_rate = 10000;
double number_of_samples = 2500;
double amplitude = 170;
double frequency_in_hz = 60;
double time_in_seconds;
double sample;

for (int sample_number = 0; sample_number < number_of_samples; sample_number++)
{
time_in_seconds = sample_number / sample_rate;
sample = amplitude * Math.Sin(2 * Math.PI * frequency_in_hz * time_in_seconds);

lstDataItems.Add(new ChartData(time_in_seconds, sample));
}

return lstDataItems;
}

public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged(string propertyName)
{
var handler = this.PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}

public List<ChartData> dataItems;
public List<ChartData> DataItems
{
set
{
dataItems = value;
this.OnPropertyChanged("DataItems");
}
get { return dataItems; }
}

}

Parents Reply Children