Live-Charts
Live-Charts copied to clipboard
Custom DataLabelTemplate not getting Pointdata
I am trying to create a Ganttchart using this package. Now I want to create a custom DataLabelTemplate and show a warning Icon on each DataPoint when a certain condition of my data is set.
How to reproduce?
<lvc:CartesianChart Grid.Row="1" Grid.Column="1" Zoom="None" DisableAnimations="True" TooltipTimeout="0">
<lvc:CartesianChart.DataTooltip >
<chart:CustomGanttTooltip />
</lvc:CartesianChart.DataTooltip>
<lvc:CartesianChart.Series>
<lvc:RowSeries FontSize="16" Configuration="{Binding Mapper}" Values="{Binding Series}" RowPadding="10" StrokeThickness="2"
DataLabels="False" LabelsPosition="Parallel" MaxRowHeigth="45">
<lvc:RowSeries.DataLabelsTemplate>
<DataTemplate DataType="{x:Type lvcCore:DataLabelViewModel}">
<Rectangle Width="20" Height="20" Visibility="{Binding Point.Instance.(ui:GanttComponent.Error), Converter={StaticResource BoolToVis}}">
<Rectangle.Fill>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M7.0002,-0.000199999999999534L0.000200000000000422,13.9998 2.0002,15.9998 14.0002,15.9998 16.0002,13.9998 9.0002,-0.000199999999999534z" />
<GeometryDrawing Brush="#FFFFCC00" Geometry="F1M9,10L7,10 7,5 9,5z M9,13L7,13 7,11 9,11z M8.382,1L7.618,1 1.217,13.803 2.5,15 13.5,15 14.783,13.803z" />
<GeometryDrawing Brush="#FF000000" Geometry="F1M9,11L7,11 7,13 9,13z M9,10L7,10 7,5 9,5z" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
</lvc:RowSeries.DataLabelsTemplate>
</lvc:RowSeries>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding Formatter}"
MinValue="{Binding From}"
MaxValue="{Binding To}">
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Labels="{Binding Labels}" FontSize="14">
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
As you can see, I try to bind the visibility of the Rectangle in the DataLabelTemplate to a value of the GanttComponent Class. But somehow either it does not change anything or every DataPoint shows the DataLabel.
Extra notes
Is it somehow possible to create the DataLabelTemplate in another class and use it just like the Tooltip? You can see in the code above that I use <chart:CustomGanttTooltip />. Can I do something similar with the DataLabelTemplate?
I am using
| LiveCharts.Wpf.Core | 0.9.8 |
| .Net Version | Net-6 |
| Windows | 10 |