This is a migrated thread and some comments may be shown as answers.

[Solved] Chart not adjusting for negative values

2 Answers 112 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ted
Top achievements
Rank 1
Ted asked on 05 Jul 2013, 06:54 PM
I feel like I've been on this forum a lot the past couple weeks! Thanks for your prompt support thus far.

I have a chart:
<telerikChart:RadCartesianChart Grid.Row="1"
                                Grid.Column="2"
                                Style="{StaticResource TrendChartStyle}"
                                x:Name="mainGridChart">
    <telerikChart:RadCartesianChart.HorizontalAxis>
        <telerikChart:CategoricalAxis Style="{StaticResource TrendAxisStyle}" />
    </telerikChart:RadCartesianChart.HorizontalAxis>
    <telerikChart:RadCartesianChart.VerticalAxis>
        <telerikChart:LinearAxis Style="{StaticResource TrendVerticalAxisStyle}" />
    </telerikChart:RadCartesianChart.VerticalAxis>
    <telerikChart:LineSeries Style="{StaticResource TrendLineStyle}"
                             ItemsSource="{Binding DataItem.LoanCount.DayTrend}"
                             Stroke="{Binding LoanCountAlert, Converter={StaticResource AlertBoolToColorConverter}}" />
</telerikChart:RadCartesianChart>


And here are the styles:
<!--Trend Chart Styles-->
<Style x:Key="TrendAxisStyle"
       TargetType="telerikChart:Axis">
    <Setter Property="Visibility"
            Value="Collapsed" />
</Style>
 
<Style x:Key="TrendVerticalAxisStyle"
       TargetType="telerikChart:LinearAxis"
       BasedOn="{StaticResource TrendAxisStyle}">
    <Setter Property="RangeExtendDirection"
            Value="None" />
    <Setter Property="MajorStep"
            Value="0" />
</Style>
 
<Style x:Key="TrendChartStyle"
       TargetType="telerikChart:RadCartesianChart">
    <Setter Property="MinHeight"
            Value="0" />
    <Setter Property="MinWidth"
            Value="0" />
    <Setter Property="Height"
            Value="20" />
    <Setter Property="Width"
            Value="100" />
    <Setter Property="Margin"
            Value="0,9" />
    <Setter Property="FontSize"
            Value="21.333" />
</Style>
 
<Style x:Key="TrendLineStyle"
       TargetType="telerikChart:LineSeries">
    <!--Global styles for the trend line can be placed here-->
</Style>


And this produces the result you can see in this img:
http://i.imgur.com/0NJ0FqH.png


You can see that "Loan to Deposit Ratio", "Deposit Balance", "Avg Bal Per Acct", and "Negative Account Bal" all have flat charts that look like the values are all zero. The values are not 0, but they are all negative values.

LoanToDepositRatio: -0.4361,-0.4360,-0.4399,-0.4399,-0.4399
Deposit Balance: -118887236890.3600,-118906226963.8900,-117866329699.8800,-117866949318.0100,-117864855883.4300
AvgBalPerAcct: -71318078.5185,-71372285.0923,-70705656.6885,-70706028.3851,-70704772.5755
NegativeAccountBal: -191268506912.2800,-191346684964.7300,-191447958253.3600,-191463073271.7000,-191470871475.3200
DepositBalPerCust: -168157336.4785,-167946648.2540,-166243060.2255,-166243934.1579,-166240981.4999
AvgCombBalPerCust: -94825918.9623,-94718203.6840,-93117904.8940,-93118997.9590,-93116047.7261

All of these charts are graphing as if the values were all zero. It seems that the vertical axis is not automatically adjusting to handle these values less than zero. I believe this is what the Minimum setting is for, so I tried setting that to Minimum="-Infinity" but then the chart doesn't display at all.

How can I get these charts to handle negative values as well as they handle positive values?

Best,
Ted

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivaylo Gergov
Telerik team
answered on 09 Jul 2013, 03:39 PM
Hello Ted,

Thank you for contacting us.

By design the linear axis of RadChart uses the following MS Excel guidelines to define its Minimum, Maximum, and MajorStep values  - http://support.microsoft.com/kb/214075. It seems that the mentioned series fall into a scenario where the Maximum is 0 and the MajorStep is relatively large in comparison to the difference between the values of the points. Therefore, the automatic range calculation makes the graph look like a straight line.

What I can suggest is that you manually control the Minimum, Maximum and MajorStep properties of the LinearAxis, in order to get a meaningful graph.

I hope this information is useful.

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ted
Top achievements
Rank 1
answered on 09 Jul 2013, 04:39 PM
Hmm that is disappointing that the chart can't automatically figure that out. But happily Minimum and Maximum are bindable properties, so I was able to manually set them as you suggested in my MVVM application.

Thanks for the response.
Tags
Chart for XAML
Asked by
Ted
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Ted
Top achievements
Rank 1
Share this question
or