简体   繁体   中英

How set Stacked=“true” column chart telerik

I have a column chart, so I would like to chart the values last columns show stacked values.

I am using the RadHtmlChart Telerik, but setting parameter tacked="true" in the last columns, but the result its wrong the chart is not stacked, if i set this attribute in the first line serie, the chart is stacked. This my code:

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

thanks for yours comments

Finally I set the property stacked= true in the last column, my code:

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

the part of code-behind:

 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

the result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM