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
780
Formatting DataPoint value in ToolTip set from Series.DataPointStyle.
posted

I'd like to set the tooltip for the datapoints in a series at the Series level using the DataPointStyle property and format the values using the same manner as I do with labels (http://help.infragistics.com/Help/NetAdvantage/DV/2009.1/CLR3.X/html/SL_DV_xamWebChart_Format_the_Labels_of_an_Axis.html).

But, when I try something like "{}{0:c}" in the ToolTip property, I get that literal value "{}{0:c}" as my tooltip instead of the formatted value.  Is there a way to reference the Value of the DataPoint in the DataPointTemplate style?  Here's what I'm trying now:

<UserControl.Resources>
        <Style x:Key="DataPointStyle1" TargetType="igChart:BarChartDataPointTemplate">
            <Setter Property="ToolTip" Value="{}{0:c}" />
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" >
        <igChart:XamWebChart x:Name="XamWebChart1" >
            <igChart:XamWebChart.Series>
                <igChart:Series ChartType="Bar" DataPointStyle="{StaticResource DataPointStyle1}" >
                    <igChart:Series.DataPoints>
                        <igChart:DataPoint Value="50" Label="Mark"  />
                        <igChart:DataPoint Value="40" Label="Joe" />
                    </igChart:Series.DataPoints>
                </igChart:Series>
            </igChart:XamWebChart.Series>
        </igChart:XamWebChart>
    </Grid>

I tried "{}{Binding Value}" as well, but that also just showed up as the literal string as the tooltip. 

Thanks,
Keith

Parents
No Data
Reply
  • 28496
    Verified Answer
    Offline posted

    i don't think it's possible to achieve this using only XAML.  when the DataPoint.ToolTip property is set, the chart simply attaches it using code like this:

    TooltipService.SetTooltip(uielement, theDataPoint.Tooltip)

    hence no formatting is possible.

    I think the best way to solve this problem is by using C#:

    foreach (DataPoint point in mySeries.DataPoints)

    {

    point.Tooltip = new TextBlock() { Text = point.Value.ToString("0:c") };

    }

Children