views:

400

answers:

1

I'd like to get suggestion in both C# and VB.NET

I created Chart like the following image:

alt text

  1. How can I customize the value on the top of each column from code-behind? Instead of showing 21, 49, 19 I'd like to show 21 hr, 49 hr, 19 hr

  2. How can I show the those values on top of other lines? As you can see 19 is below the Line series.

  3. Can I set draw the line across the Chart Area not just across the column? So, the line will start from Axis X to end of the Chart Area.

Here's the mark-up:

 <asp:chart id="Chart1" runat="server" Height="296px" Width="500" ImageLocation="~/TempChartFiles/ChartPic_#SEQ(300,3)" Palette="BrightPastel" imagetype="Png" BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105">
                    <legends>
                        <asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend>
                    </legends>
                    <borderskin skinstyle="Emboss"></borderskin>
                    <series>
                        <asp:Series Name="Month" BorderColor="180, 26, 59, 105" IsValueShownAsLabel="true">
                        </asp:Series>
                    </series>
                    <chartareas>
                        <asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom">
                            <area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>
                            <axisy linecolor="64, 64, 64, 64">
                                <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />
                                <majorgrid linecolor="64, 64, 64, 64" />
                            </axisy>
                            <axisx linecolor="64, 64, 64, 64">
                                <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />
                                <majorgrid linecolor="64, 64, 64, 64" />
                            </axisx>
                        </asp:ChartArea>
                    </chartareas>
                </asp:chart>

Here's the code-behind:

Chart1.ChartAreas("ChartArea1").AxisX.Interval = 1

    ' Create new data series and set its visual attributes
    Dim series As New Series("Minimum Hour")

    series.ChartType = SeriesChartType.Line
    series.BorderWidth = 2
    series.ShadowOffset = 1
    series.AxisLabel = 0


    Dim monthyHour = 22
    series.Name = "Min. Hour : " & monthyHour

    Dim xValue() As String = {"Jun", "Jul", "Aug"}
    Dim yValue() As Integer = {21, 49, 19}

    'add value for Line series
    For i = 0 To xValue.Length - 1 Step 1

         series.Points.AddY(monthyHour)

    Next

    Chart1.Series(0).Points.DataBindXY(xValue, yValue)

    ' Add series into the chart's series collection
    Chart1.Series.Add(Series)
A: 

To add it from code behind u need to set Chart1.Series(0).Label=monthyHour +"Hrs"

Anuja

Anuja Pawar