Hello everyone,
I am trying to draw a scatter Chart using WPF Chart toolkit.
My datasource is DataTable.
My Goal is to fill the datapoints dynamically(I have changed the shape of scatter datapoint to rectangle).
For that , I am using Lineargradient brush.
The Problem is, I have different Offset value for each Point. I could not achieve this Feature.
I am able to fill the datapoint with fixed Offset value.
Could someone tell me how to achieve this?
Here is my code so far.
Below, In my code, I have tried to bind the Offset value to DataTable column.
My table structure is
I have checked this Thread . In that thread he mentioned ist not possible.
but Is it possible to add scatter Points dynamically and mention Offset value for each datapoint?
<charting:Chart HorizontalAlignment="Left" Grid.Row="1" Title="Chart Title" VerticalAlignment="Top" Name="mcChart"
BorderBrush="White" Width="520" Height="423"><charting:Chart.Series><charting:ScatterSeries Title="AbsentList" x:Name="myChart" ItemsSource="{Binding}" IndependentValuePath ="WeekDay" DependentValuePath="OpId" Margin="0,0,0,1" ><charting:ScatterSeries.DataPointStyle><Style TargetType="charting:ScatterDataPoint"><Setter Property="BorderBrush" Value="Black" /><Setter Property="Width" Value="50"/><Setter Property="Height" Value="20"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="charting:ScatterDataPoint"><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"><Border.Background><LinearGradientBrush StartPoint="0 0" EndPoint="1 0"><GradientStop Color="Green" Offset="0"/><GradientStop Color="Green" Offset="{Binding Path=Length}"/><GradientStop Color="Red" Offset="{Binding Path=AnotherLength}"/><GradientStop Color="Red" Offset="1"/></LinearGradientBrush></Border.Background><StackPanel Orientation="Horizontal"><Rectangle Height="{Binding Height}" Stroke="{Binding BorderBrush}" StrokeThickness="3" Width="{Binding Width}"></Rectangle></StackPanel></Border></ControlTemplate></Setter.Value></Setter></Style></charting:ScatterSeries.DataPointStyle></charting:ScatterSeries></charting:Chart.Series><charting:Chart.Axes><charting:LinearAxis Orientation="Y" Minimum="1" Maximum="30" Interval="2" ShowGridLines="False"/><charting:CategoryAxis Orientation="X" ShowGridLines="False"/></charting:Chart.Axes></charting:Chart>Thanks in advance