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

AutoRange issue with LinearAxis

8 Answers 574 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Timo
Top achievements
Rank 1
Timo asked on 08 Dec 2011, 11:47 AM
Hi,

I have a chart with a horizontal DateTimeContinuousAxis and a vertical LinearAxis.
<telerik:RadCartesianChart Background="red" x:Name="chart" MinWidth="400" MinHeight="300" >
          <telerik:RadCartesianChart.Behaviors>
                   <telerik:ChartPanAndZoomBehavior PanMode="Both" ZoomMode="Both"/>
          </telerik:RadCartesianChart.Behaviors>
          <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeContinuousAxis LabelInterval="1" MajorStepUnit="Minute" LabelFitMode="None"    PlotMode="OnTicks" LastLabelVisibility="Hidden">
               </telerik:DateTimeContinuousAxis>
                </telerik:RadCartesianChart.HorizontalAxis>
           <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis />
           </telerik:RadCartesianChart.VerticalAxis>
</telerik:RadCartesianChart>

If I have the following code, the vertical axis will auto arrange itself.

var items = new List<Vm>();
 var data = new DateTime(2011, 12, 1);
 for (int i = 0; i < 12; i++)
      {
          double? val = (i % 4) + 10;
          if (val == 10)
               val = null;
           items.Add(new Vm { Date = data.AddDays(i), Value = val});
       }
  var rz = items.Where(ee => ee.Value.HasValue).ToList();
  this.chart.Series[0].ItemsSource = rz;
  (chart.HorizontalAxis as DateTimeContinuousAxis).Maximum = new DateTime(2011, 12, 15);
  (chart.HorizontalAxis as DateTimeContinuousAxis).Minimum = new DateTime(2011, 12, 1).AddDays(1);
 
public class Vm
   {
       public DateTime Date { get; set; }
       public double? Value { get; set; }
   }


But if I change to the following

var items = new List<Vm>();
var data = new DateTime(2011, 12, 1);
for (int i = 0; i < 12; i++)
{
    double? val = (i % 4) + 10;
    //if (val == 10)
    //    val = null;
    items.Add(new Vm { Date = data.AddDays(i), Value = val});
}
var rz = items.Where(ee => ee.Value.HasValue).ToList();
this.chart.Series[0].ItemsSource = rz;
(chart.HorizontalAxis as DateTimeContinuousAxis).Maximum = new DateTime(2011, 12, 15);
(chart.HorizontalAxis as DateTimeContinuousAxis).Minimum = new DateTime(2011, 12, 1).AddDays(1);

the vertical axis will no longer arrange itself to the minimum of the series, but the minimum will become 0.

All I want is to display a chart from moment A to B, and the points in A and B to be displayed right to the start and right to the end of the chart ( no space before first point - that's why I have set PlotMode on horizontal Axis to "OnTicks") and the linearAxis to auto arrange itself without computing minimum and maximum of it.

8 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 12 Dec 2011, 05:46 PM
Hi Timo,

The automatic axis range calculation in RadChartView mimics the behavior of MS Excel -- see this KB article here ("If the difference between yMax and yMin is greater than 16.667 percent of the value of yMax, the automatic minimum for the y-axis is zero.").

However, you can manually tweak this behavior by setting the LinearAxis.RangeExtendDirection property to NumericalAxisRangeExtendDirection.None or NumericalAxisRangeExtendDirection.Positive.

Hope this helps.


Greetings,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sebastian
Top achievements
Rank 1
answered on 04 Jan 2012, 11:59 AM
Hi,

I am also having the same problem but with the DateTimeCategoricalAxis. I want values of 0 to start in the chart from 0,0 coordinate.
However i don´t seem too find the LinearAxis.RangeExtendDirection on the DateTimeCategoricalAxis.

<telerik:RadCartesianChart.HorizontalAxis>
    <telerik:DateTimeCategoricalAxis DateTimeComponent="Millisecond" />
</telerik:RadCartesianChart.HorizontalAxis>

Any input on this?

//Sebastian
0
Giuseppe
Telerik team
answered on 09 Jan 2012, 09:39 AM
Hello Sebastian,

You cannot extend the range (neither set the range manually) for a CategoricalAxis / DateTimeCategoricalAxis as this axis type represents discrete values (categories) that should be user-defined.

Could you elaborate a bit more on the "I want values of 0 to start in the chart from 0,0 coordinate" requirement in the context of DateTime axis?


Kind regards,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sebastian
Top achievements
Rank 1
answered on 16 Jan 2012, 05:01 PM
Hi Giuseppe,

What i mean is that i would like to remove the space between the Y-axis and the 0-point on the X-axis. I have attached a picture illustrating the space that i want to remove. Hope this makes my explanation clearer.

Regards,
Sebastian
0
Giuseppe
Telerik team
answered on 19 Jan 2012, 01:02 PM
Hello Sebastian,

Provided that your Y-axis (the vertical one) is linear, you should be able to modify its LinearAxis.RangeExtendDirection property and not any property on the DateTimeCategoricalAxis (the horizontal one).


Regards,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sebastian
Top achievements
Rank 1
answered on 19 Jan 2012, 01:53 PM
Hi Giuseppe,

I have tried all the different types of RangeExtendDirections. However i am not getting rid of the gap between my Y-axis (the vertical one) and the 0-value on my X-axis.

I am grateful for the help so far. I have pasted my code if that will help.
<telerik:RadCartesianChart x:Name="radc" Height="200" Background="Green" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
           <telerik:RadCartesianChart.Behaviors>
               <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True"
                                        ShowTrackInfo="True" SnapMode="None"/>
           </telerik:RadCartesianChart.Behaviors>
           <telerik:RadCartesianChart.VerticalAxis>
               <telerik:LinearAxis ShowLabels="True" RangeExtendDirection="None" Visibility="Visible"/>
           </telerik:RadCartesianChart.VerticalAxis>
           <telerik:RadCartesianChart.HorizontalAxis>                
               <telerik:DateTimeCategoricalAxis DateTimeComponent="Millisecond" HorizontalContentAlignment="Stretch"/>
           </telerik:RadCartesianChart.HorizontalAxis>
           <telerik:LineSeries Stroke="Orange" StrokeThickness="2" CategoryBinding="When" ValueBinding="VitalValue" ItemsSource="{Binding FakeVitals}">
               <telerik:LineSeries.PointTemplate>
                   <DataTemplate>
                       <Ellipse Width="4" Height="4" Fill="Aquamarine"></Ellipse>
                   </DataTemplate>
               </telerik:LineSeries.PointTemplate>
               <telerik:LineSeries.TrackBallTemplate>
                   <DataTemplate>
                       <Rectangle Width="20"
                      Height="20"
                      Fill="Violet"
                      RenderTransformOrigin="0.5,0.5">
                           <Rectangle.RenderTransform>
                               <RotateTransform Angle="45"/>
                           </Rectangle.RenderTransform>
                       </Rectangle>
                   </DataTemplate>
               </telerik:LineSeries.TrackBallTemplate>
           </telerik:LineSeries>
 
           <telerik:LineSeries Stroke="Chocolate" StrokeThickness="2" CategoryBinding="When" ValueBinding="VitalValue" ItemsSource="{Binding FakeVitals2}" />
       </telerik:RadCartesianChart>

Regards,
Sebastian
0
Ves
Telerik team
answered on 24 Jan 2012, 08:40 AM
Hi Sebastian,

You can set the PlotMode property of the DateTimeCategoricalAxis to AxisPlotMode.OnTicks. This will place the labels right under their corresponding ticks and not between the ticks, as shown in this example.

Best regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sebastian
Top achievements
Rank 1
answered on 22 Feb 2012, 12:47 PM
Hi Ves,

Sorry for the late answer.
Yes that seemed to fix it now the lineseries starts from the 0,0 position in the Chart.

Thanks,
Sebastian
Tags
ChartView
Asked by
Timo
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Sebastian
Top achievements
Rank 1
Ves
Telerik team
Share this question
or