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
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