如何设置Stacked =" true"柱形图telerik

时间:2014-05-06 20:58:07

标签: asp.net vb.net charts telerik

我有一个柱形图,所以我想绘制最后一列显示堆积值的值。

我正在使用RadHtmlChart Telerik,但在最后一列中设置参数tacked =“true”,但结果错误,图表未堆叠,如果我在第一行系列中设置此属性,则图表会堆叠。这是我的代码:

<telerik:RadHtmlChart ID="Chart" runat="server" Width="680" Height="500">
                                <PlotArea>
                                    <XAxis>
                                        <LabelsAppearance>
                                            <TextStyle Color="white" FontFamily="Arial" FontSize="13" />
                                        </LabelsAppearance>
                                    </XAxis>
                                    <YAxis Step="5000000" MinValue="0" > 
                                        <LabelsAppearance DataFormatString="${0:0,0}">
                                            <TextStyle Color="white" FontFamily="Arial" FontSize="12" />
                                        </LabelsAppearance>
                                    </YAxis>
                                    <Series>
                                        <telerik:ColumnSeries Name="Garantías Vigentes">
                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}" >
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18"  />
                                            </LabelsAppearance>
                                            <Appearance>
                                                <FillStyle BackgroundColor="#87cb50"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>
                                            </SeriesItems>
                                        </telerik:ColumnSeries>
                                        <telerik:ColumnSeries Name="Saldo Vigente" Stacked="true">
                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
                                            </LabelsAppearance>
                                            <Appearance>
                                                <FillStyle BackgroundColor="#8DB4E2"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>
                                            </SeriesItems>
                                        </telerik:ColumnSeries>
                                        <telerik:ColumnSeries Name="" Stacked="true">
                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
                                            </LabelsAppearance>
                                            <Appearance>
                                                <FillStyle BackgroundColor="#8DB4E2"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>
                                            </SeriesItems>
                                        </telerik:ColumnSeries>
                                    </Series>
                                </PlotArea>
                                <Legend>
                                    <Appearance Position="Bottom"><TextStyle Color="white" FontFamily="Arial" FontSize="20" Bold="True"/></Appearance>
                                </Legend>
     </telerik:RadHtmlChart>

感谢您的评论

2 个答案:

答案 0 :(得分:0)

阅读本文以了解如何使用该功能:http://www.telerik.com/help/aspnet-ajax/htmlchart-stacked-series.html

阅读本文,了解如何在上一个系列中获得总数:http://www.telerik.com/forums/need-to-display-grand-total-on-top-of-the-htmlchart-stacked-bars

答案 1 :(得分:0)

最后我在最后一栏设置了属性stacked = true,我的代码是:

<telerik:RadHtmlChart ID="Chart" runat="server" Width="680" Height="500">
                                <PlotArea>
                                    <XAxis>
                                        <LabelsAppearance>
                                            <TextStyle Color="white" FontFamily="Arial" FontSize="13" />
                                        </LabelsAppearance>
                                    </XAxis>
                                    <YAxis MinValue="0" > 
                                        <LabelsAppearance DataFormatString="${0:0,0}">
                                            <TextStyle Color="white" FontFamily="Arial" FontSize="12" />
                                        </LabelsAppearance>
                                    </YAxis>

                                      <Series>
                                        <telerik:ColumnSeries Name="Garantías Vigentes" Stacked="true">

                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
                                            </LabelsAppearance>
                                            <Appearance>
                                                <FillStyle BackgroundColor="#87cb50"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>

                                            </SeriesItems>
                                        </telerik:ColumnSeries>
                                    </Series>

                                    <Series>                         
                                        <telerik:ColumnSeries Name="Saldo Vigente" Stacked="true">
                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
                                            </LabelsAppearance>
                                            <Appearance>
                                                <FillStyle BackgroundColor="#8DB4E2"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>
                                                <telerik:CategorySeriesItem Y="0"></telerik:CategorySeriesItem>
                                            </SeriesItems>
                                        </telerik:ColumnSeries>

                                       <telerik:ColumnSeries Name="" >
                                            <LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
                                                <TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="0" />
                                            </LabelsAppearance>
                                            <Appearance>
                                                 <FillStyle BackgroundColor="#1B1A1A"></FillStyle>
                                            </Appearance>
                                            <SeriesItems>
                                                <telerik:CategorySeriesItem Y="0"></telerik:CategorySeriesItem>
                                            </SeriesItems>
                                        </telerik:ColumnSeries>
                                    </Series> 
                                </PlotArea>
                                <Legend>
                                    <Appearance Position="Bottom"><TextStyle Color="white" FontFamily="Arial" FontSize="20" Bold="True"/></Appearance>
                                </Legend>
        </telerik:RadHtmlChart>

代码隐藏的部分:

 Public Sub LoadChart()
    Dim salesAuto As Double
    Dim lessVig As Double

    lessVig = LtlSaldoVigente.Text.ToDouble
    salesAuto = CDbl(LtlLine.Text.ToDouble - lessVig * 1000000)
    Chart.PlotArea.YAxis.MinorGridLines.Visible = False
    Chart.PlotArea.XAxis.MinorGridLines.Visible = False


    Dim ColumnSeries1 As ColumnSeries = TryCast(Chart.PlotArea.Series(0), ColumnSeries)
    ColumnSeries1.SeriesItems.Add(y:=CDec(LtlValue.Text.ToDouble))
    ColumnSeries1.SeriesItems.Add(y:=CDec(0))

    Dim ColumnSeries2 As ColumnSeries = TryCast(Chart.PlotArea.Series(1), ColumnSeries)
    ColumnSeries2.Stacked = True
    ColumnSeries2.SeriesItems.Add(y:=CDec(LtlSaVig.Text.ToDouble * 1000000))

    Dim ColumnSeries3 As ColumnSeries = TryCast(Chart.PlotArea.Series(2), ColumnSeries)
    ColumnSeries3.SeriesItems.Add(y:=CDec(lessVig))
End Sub

结果:

enter image description here