none
MSChart について教えてください RRS feed

  • 質問

  • データベースに

    fruit テーブル
    ID fruit eatDay
    1 りんご 2010-07
    2 りんご 2010-06
    3 ぶどう 2010-06
    4 りんご 2010-08
    5 りんご 2010-04
    6 ぶどう 2010-04

    とし 下記にあるコードを実行すると

    青=10-1Q 黄=10-2Q
    | 2     2  2
    || |   | ∥ |
    ||青|   |青∥黄|
    || |0   | ∥ |
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
     ぶどう    りんご

    となりますが
    これを

    青=ぶどう 黄=りんご
    | 2     2  2
    || |   | ∥ |
    ||青|  |黄∥黄|
    || |    | ∥ |
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
     10-1Q10-2Q 10-1Q10-2Q  
      ぶどう   りんご

    となるように
    ① 0の場合、ラベルを表示させない
    ② ぶどうを青、りんごを黄にしたい
    ③ 軸に1Q-10,2Q-10となるようにしたい

    のですがどのようにしたらいいのでしょうか?

    教えてください。

    <%@ Page Language="VB" %>
    <%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim sqldatasource As New SqlDataSource()
        sqldatasource.ID = "sds"
    
        sqldatasource.ConnectionString = ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString
        sqldatasource.SelectCommand = "Select sum(case when(eatDay = '2010-04' OR eatDay = '2010-05' OR eatDay = '2010-06') THEN 1 ELSE 0 END) AS [10-1Q], sum(case when(eatDay = '2010-07' OR eatDay = '2010-08' OR eatDay = '2010-09') THEN 1 ELSE 0 END) AS [10-2Q],fruit FROM fruit GROUP BY fruit"
        Me.Controls.Add(sqldatasource)
      
        Dim chart As New Chart()
        chart.DataSourceID = "sds"
        chart.Width = 600
      
        Dim chartArea As New ChartArea()
        chartArea.Name = "ChartArea1"
        chart.ChartAreas.Add(chartArea)
      
        chart.ChartAreas(0).AxisX.LabelStyle.Interval = 1
        
        
        Dim s As Series
      
        s = New Series()
        s.Name = "10-1Q"
        s.ChartType = SeriesChartType.Column
        s.CustomProperties = "DrawingStyle=Cylinder"
        s.IsValueShownAsLabel = True
        s.Label = "#VALY"
        s.Legend = "Legend1"
        s.XValueMember = "fruit"
        s.YValueMembers = "10-1Q"
        chart.Series.Add(s)
      
        s = New Series()
        s.Name = "10-2Q"
        s.ChartType = SeriesChartType.Column
        s.CustomProperties = "DrawingStyle=Cylinder"
        s.IsValueShownAsLabel = True
        s.Label = "#VALY"
        s.Legend = "Legend1"
        s.XValueMember = "fruit"
        s.YValueMembers = "10-2Q"
        chart.Series.Add(s)
      
        Dim legend As New Legend()
        legend.DockedToChartArea = "ChartArea1"
        legend.IsDockedInsideChartArea = False
        legend.Name = "Legend1"
        chart.Legends.Add(legend)
      
        Me.Controls.Add(chart)
      End Sub
    
    
    
    </script>
    
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head id="Head1" runat="server">
    
     <title>無題のページ</title>
    
    </head>
    
    <body> 
    
     <asp:Chart ID="Chart1" runat="server">
    
     </asp:Chart>
    
    </body>
    
    </html>
    
    

     

    2010年7月24日 8:06