Wie fügen Sie andere Farbe der Spalte in Diagramm-Steuerelement in asp.net

Ich mache Codierung ASP.NET chart-Steuerelement und Diagramm-code wie unten beschrieben

<asp:Chart ID="Chart1" runat="server" Width="450px" Height="200px" BackColor="211, 223, 240"
                Palette="None" BorderLineStyle="Solid" BackGradientEndColor="White" BackGradientType="TopBottom"
                BorderlineWidth="2" BorderlineColor="26, 59, 105" EnableViewState="True">
                <Series>
                    <asp:Series Name="Series1" BorderColor="180, 26, 59, 105" Color="Blue" BorderWidth="2"
                        ShadowColor="254, 0, 0, 0" ChartType="Column" ShadowOffset="1" MarkerSize="8" MarkerStyle="Diamond">
                        <EmptyPointStyle BackGradientStyle="Center" />
                    </asp:Series>                         
                <ChartAreas>
                    <asp:ChartArea Name="ChartArea" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
                        BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
                        BackGradientStyle="TopBottom">
                        <AxisY LineColor="#eb9c28">
                            <MajorGrid LineColor="64, 64, 64, 64"></MajorGrid>
                        </AxisY>
                        <AxisX LineColor="64, 64, 64, 64" TextOrientation="Horizontal" IsStartedFromZero="true">
                            <LabelStyle Format="dd/MM/yyyy" IntervalType="Days" Interval="1"></LabelStyle>
                            <MajorGrid LineColor="64, 64, 64, 64"></MajorGrid>
                        </AxisX>
                    </asp:ChartArea>
                </ChartAreas>
                <BorderSkin SkinStyle="Emboss" />
            </asp:Chart>

und ich haben binden Sie das Diagramm-Steuerelement aus code hinter wie pro unten

    Chart1.DataSource = dt;
    Chart1.Series["Series1"].XValueMember = "UTC";
    Chart1.Series["Series1"].YValueMembers = "Value";           

    Chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Minutes;
    Chart1.ChartAreas[0].AxisX.Interval = 5;
    Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss"; 

Nun in dt (datasource) es gibt auch 3. Säule genannt, wie Schwere und Werte "a", "b","c" ...

Nun würde ich gerne anpassen Spalte Farbe wie pro dieser Wert, bedeutet

wenn a -> Rot

b -> Blau

c -> grün wie das

Bitte helfen Sie mir, wenn jemand hat dies getan Art der Logik.

Vielen Dank im Voraus.

InformationsquelleAutor Arun Rana | 2011-12-15

Schreibe einen Kommentar