Tracker custom precision

Oystein Bjorke 5 years ago 0
This discussion was imported from CodePlex

krafty wrote at 2013-07-23 11:43:

Hi,

I wanted to round off the double precision displayed in the tracker X and Y values .. using some custom rounding values. Is it possible to do with the current tracker?

Thanks

everytimer wrote at 2013-07-23 12:21:

See Tracker Examples
  <oxy:Plot.DefaultTrackerTemplate>
                <ControlTemplate>

                    <oxy:TrackerControl Position="{Binding Position}" BorderThickness="2" BorderBrush="LightSteelBlue" LineStroke="SteelBlue" LineExtents="{Binding PlotModel.PlotArea}">
                        <oxy:TrackerControl.Background>
                            <LinearGradientBrush EndPoint="0,1">
                                <GradientStop Color="#B0C4DE" />
                                <GradientStop Offset="1" Color="#f0ffffff" />
                            </LinearGradientBrush>
                        </oxy:TrackerControl.Background>
                        <oxy:TrackerControl.Content>

                            <UniformGrid  Columns="2" Canvas.Left="{Binding Position.X}" Canvas.Top="{Binding Position.Y}" Margin="6">
                                <TextBlock Text="{Binding Series.Title}" FontWeight="Bold" FontSize="15" Foreground="Black" />
                                <TextBlock Text="{Binding Series.Tag}" Foreground="Black"/>
                                <TextBlock>
                                    <Run Text="X:" FontWeight="Bold" Foreground="Black" />
                                    <Run Text="{Binding DataPoint.X, StringFormat='{}{0:0.000}'}" Foreground="Black"/>
                                </TextBlock>
                                <TextBlock>
                                    <Run Text="Y:" FontWeight="Bold" Foreground="Black" />
                                    <Run Text="{Binding DataPoint.Y, StringFormat='{}{0:0.000}'}" Foreground="Black" />
                                </TextBlock>
                            </UniformGrid>

                        </oxy:TrackerControl.Content>
                    </oxy:TrackerControl>

                </ControlTemplate>
            </oxy:Plot.DefaultTrackerTemplate>
Good luck

krafty wrote at 2013-07-23 13:11:

Hi everytimer..

Thanks for the example. I have seen it but I don't think its dynamically possible to change the precision with it?
StringFormat='{}{0:0.000}'

everytimer wrote at 2013-07-23 13:39:

I think you should create a custom Series derived from LineSeries with the TrackerFormatString property exposed. See MatrixSeries.cs.

Good luck

raphay wrote at 2013-07-23 13:41:

Just put StringFormat='{}{0:0.0}' for only one decimal for example.
If you want more explanation about double format : http://www.csharp-examples.net/string-format-double/

krafty wrote at 2013-07-23 14:04:

Thanks everytimer... That's a good idea, it will work!

krafty wrote at 2013-07-23 14:08:

Thanks raphay.. But my query was more towards the binding aspect.
cheers.
CodePlex