Open rentocika opened 6 years ago
Please see answer on StackOverflow: https://stackoverflow.com/questions/47553610/interactivedatadisplay-wpf-making-dynamically-chart-as-values-recorder-appearanc/47589722#47589722
Time axis (Y) not move with adding datas. How to fix this?
Where you are?
What about solution for this behavior or bug?
Hi, i had a similar problem, and found a solution (or workaround) :
In your xaml, in the Window.Resources
tag, add a style for a d3:PlotAxis
:
<Style TargetType="d3:PlotAxis" x:Key="PlotDate">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="d3:PlotAxis">
<Grid>
<custom:DateAxis x:Name="PART_Axis"
AxisOrientation="{Binding AxisOrientation, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Ticks="{Binding Ticks, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Foreground="{Binding Foreground, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="IsTabStop" Value="False"/>
</Style>
Then, in the ControlTemplate for the Chart, replace your custom axis (for the date) by a d3:PlotAxis
with the new Style :
<d3:PlotAxis x:Name="PART_horizontalAxis"
d3:Figure.Placement="Bottom"
AxisOrientation="Bottom"
Style="{DynamicResource PlotDate}"
Foreground="{TemplateBinding Foreground}">
<d3:MouseNavigation IsHorizontalNavigationEnabled="{TemplateBinding IsHorizontalNavigationEnabled}" IsVerticalNavigationEnabled="{TemplateBinding IsVerticalNavigationEnabled}"/>
</d3:PlotAxis>
It should now work as expected. You might need to rework your LabelProvider though, as the ticks provided will not always be in the 0 to 1 range.
I hope my explanations were clear, and that it can help (even if the issue is almost 3 years old).
@stanislas-mur Thanks for helping, but I think there is an error:
<Grid>
<custom:DateAxis x:Name="PART_Axis"
AxisOrientation="{Binding AxisOrientation, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Ticks="{Binding Ticks, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Foreground="{Binding Foreground, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
<ContentPresenter/>
</Grid>
What do you think ?
I copy-pasted the code from my project (which works), but there might be differences between our codes. So maybe there is an error, but I don't see it unfortunately.
@stanislas-mur I have error on line:
<custom:DateAxis x:Name="PART_Axis"
The "custom" is not defined. It is your project name or what?
yes it is the namespace for my DateAxis. Replace it by your declared namespace (my bad)
I've use IDD.WPF in my little WPF app for charting a real time data's. But I've a few problems - see the attached picture or follow https://stackoverflow.com/questions/47553610/interactivedatadisplay-wpf-making-dynamically-chart-as-values-recorder-appearanc