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

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

1 Answer 35 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Ravi Kumar
Top achievements
Rank 1
Ravi Kumar asked on 11 Apr 2011, 08:40 AM
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


1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Apr 2011, 09:19 AM
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.

Tags
Chart (Obsolete)
Asked by
Ravi Kumar
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or