How to set YAxis2 scale in HH:mm format with step 8. Please help... Its urgent

Thread is closed for posting
2 posts, 0 answers
  1. Ravi Kumar
    Ravi Kumar avatar
    37 posts
    Member since:
    May 2010

    Posted 11 Apr 2011 Link to this post

    Hi Guys,
    i,m new bee for telerik chart. i want to set YAxis2 scale range with 8 hours step for stacked bar value. i have tried. but its not giving correct result. please help me, its very very urgent.

     protected void EmployeesChart_BeforeLayout(object sender, EventArgs e)
            {
                foreach (LabelItem item in EmployeesChart.Legend.Items)
                {
                    item.Marker.Appearance.Figure = Telerik.Charting.Styles.DefaultFigures.Rectangle;
                    item.Marker.Appearance.Dimensions.Width = 25;
                }
               
                int mins = 0;
                int hours = 0;
                foreach (ChartAxisItem axisItem in EmployeesChart.PlotArea.YAxis2.Items)
                {
                    axisItem.TextBlock.Text = string.Format("{0:0}", hours) + ":" + string.Format("{0:00}", mins);
                    hours = hours + 8;
                }


            }

    HTML:
    <telerik:RadChart ID="EmployeesChart" runat="server" OnBeforeLayout="EmployeesChart_BeforeLayout"
            OnClick="EmployeesChart_Click" DefaultType="StackedBar" Width="750" SeriesOrientation="Horizontal"
            Style="margin-left: 100px">
            <ChartTitle TextBlock-Appearance-AutoTextWrap="Auto" TextBlock-Text="Week-to-Date Labor Hours by Employee">
                <Appearance Position-AlignedPosition="Top">
                </Appearance>
            </ChartTitle>
            <Series>
                <telerik:ChartSeries Name="Regular" Type="StackedBar">
                    <Appearance>
                        <Border Visible="false" />
                        <FillStyle FillType="Solid" MainColor="79, 129, 189">
                        </FillStyle>
                        <LabelAppearance Position-AlignedPosition="Center" Distance="10" Visible="true">
                        </LabelAppearance>
                        <TextAppearance TextProperties-Color="Black">
                        </TextAppearance>
                        <Border Color="136, 166, 78" />
                    </Appearance>
                </telerik:ChartSeries>
                <telerik:ChartSeries Name="Overtime" Type="StackedBar">
                    <Appearance>
                        <Border Visible="false" />
                        <FillStyle FillType="Solid" MainColor="192, 80, 77">
                        </FillStyle>
                        <LabelAppearance Position-AlignedPosition="Center" Distance="10" Visible="False">
                        </LabelAppearance>
                        <TextAppearance TextProperties-Color="Black">
                        </TextAppearance>
                        <Border Color="136, 166, 78" />
                    </Appearance>
                </telerik:ChartSeries>
                <telerik:ChartSeries Name="Projected" Type="StackedBar">
                    <Appearance>
                        <Border Visible="false" />
                        <FillStyle FillType="Solid" MainColor="134,134, 134">
                        </FillStyle>
                        <LabelAppearance Position-AlignedPosition="Center" Visible="true">
                        </LabelAppearance>
                        <TextAppearance TextProperties-Color="Black">
                        </TextAppearance>
                        <Border Color="136, 166, 78" />
                    </Appearance>
                </telerik:ChartSeries>
            </Series>
            <PlotArea>
                <XAxis VisibleValues="Positive" Visible="True">
                    <AxisLabel Visible="true">
                        <TextBlock Text="Employees">
                        </TextBlock>
                        <Appearance Position-AlignedPosition="Center">
                        </Appearance>
                    </AxisLabel>
                    <Appearance>
                        <MajorGridLines Color="134, 134, 134" Width="0" />
                        <TextAppearance TextProperties-Color="Black">
                        </TextAppearance>
                    </Appearance>
                    <AxisLabel>
                        <Appearance RotationAngle="270">
                        </Appearance>
                        <TextBlock>
                            <Appearance TextProperties-Color="Black">
                            </Appearance>
                        </TextBlock>
                    </AxisLabel>
                </XAxis>
                <YAxis2 VisibleValues="Positive" Visible="True">
                    <AxisLabel Visible="true">
                        <TextBlock Text="Hours">
                            <Appearance TextProperties-Color="Black">
                            </Appearance>
                        </TextBlock>
                        <Appearance Position-AlignedPosition="Bottom">
                        </Appearance>
                    </AxisLabel>
                    <Appearance ValueFormat="ShortTime">
                        <MajorGridLines Color="134, 134, 134" Width="0" />
                        <TextAppearance TextProperties-Color="Black">
                        </TextAppearance>
                    </Appearance>
                    <AxisLabel>
                        <Appearance RotationAngle="0">
                        </Appearance>
                    </AxisLabel>
                </YAxis2>
                <YAxis Visible="False" VisibleValues="All">
                </YAxis>
            </PlotArea>
        </telerik:RadChart>

    Thanks
    Ravi


  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 14 Apr 2011 Link to this post

    Hi Ravi Kumar,

    RadChart uses auto range to automatically calculate the range of your axes. To override the automatic calculation and set custom step you can write the following markup:
    <YAxis2 AutoScale="false" MinValue="0" MaxValue="104" Step="8">
    Notice that you have to specify Min and Max value. This is because overriding automatic range you take the responsibility of specifying the range. You can specify this either in markup or in code behind. If you choose to specify it in markup you can safely remove the statements in code behind that configure the range.

    Hope this helps!

    Kind regards,
    Yavor Ivanov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top