vb.net : How to create chart multiples series from SQL request

Hi,
I'm trying to make a nice chart like this one :
dNbfs.pngDatas are coming from a SQL resquest which output like this :
Col1                     Col2                    Col3
2008                    Item 1                  13
2008                    Item 2                  98
2008                    Item 3                  74
2009                    Item 1                  19
2009                    Item 2                  78

and so on.....

Open in new window


My problem is that I can find the way to create the output I'd like.
My last code is :
   <asp:Chart ID="Chart1" runat="server" DataSourceID="AccessDataSource1" 
        Height="558px" Palette="Bright" Width="930px">
        <Series>
            <asp:Series Legend="Legend1" Name="Item1" XValueMember="Col2" 
                YValueMembers="Col3" YValuesPerPoint="6">
            </asp:Series>
            <asp:Series ChartArea="ChartArea1" Legend="Legend1" Name="Item2" 
                XValueMember="Col2" YValueMembers="Col3">
            </asp:Series>
            <asp:Series ChartArea="ChartArea1" Legend="Legend1" Name="Item3" 
                XValueMember="Col2" YValueMembers="Col3">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </ChartAreas>
        <Legends>
            <asp:Legend Name="Legend1">
            </asp:Legend>
        </Legends>
        <Titles>
            <asp:Title Name="test 1">
            </asp:Title>
        </Titles>
    </asp:Chart>

Open in new window


for the following output :
output.PNG
Any help will be very welcome !
SybuxAsked:
Who is Participating?
 
Bob LearnedCommented:
You need 1 data series with data with "item1", and then another data series with "item 2", and then another data series with "item 3", so you would need more columns of data.

Year              Item 1         Item 2      Item 3

2008              13                  98              74
2009              19                  78
0
 
Bob LearnedCommented:
I don't understand what you are looking to add to your chart.  Is it labels?
0
 
SybuxAuthor Commented:
I want to see 3 columns for 2008, 3 for 2009 and not as shown on my last chart
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Bob LearnedCommented:
Without labels on the X-axis, I have no way of knowing where the divisions are, without looking at the code.
0
 
SybuxAuthor Commented:
Sorry it was late yesterday when I create the post.

Based on the data, I'd like to output this chart :

Capture.PNG
0
 
Bob LearnedCommented:
You would need 3 different series that had data for 2008 and 2009, like this:

 <asp:Series Legend="Legend1" Name="Item1" ChartArea="ChartArea1" IsValueShownAsLabel="True" >
                <Points>
                    <asp:DataPoint XValue="2008" YValues="13" />
                    <asp:DataPoint XValue="2009" YValues="19" />
                </Points>
            </asp:Series>
            <asp:Series Legend="Legend1" Name="Item2" ChartArea="ChartArea1" IsValueShownAsLabel="True">
                <Points>
                    <asp:DataPoint XValue="2008" YValues="98" />
                    <asp:DataPoint XValue="2009" YValues="78" />
                </Points>
            </asp:Series>
            <asp:Series Legend="Legend1" Name="Item3" ChartArea="ChartArea1" IsValueShownAsLabel="True">
                <Points>
                    <asp:DataPoint XValue="2008" YValues="74" />
                </Points>
            </asp:Series>

Open in new window

0
 
Bob LearnedCommented:
Full chart:

 <asp:Chart ID="Chart1" runat="server" Height="558px" Palette="Bright" Width="930px">
        <Series>
            <asp:Series Legend="Legend1" Name="Item1" ChartArea="ChartArea1" IsValueShownAsLabel="True" >
                <Points>
                    <asp:DataPoint XValue="2008" YValues="13" />
                    <asp:DataPoint XValue="2009" YValues="19" />
                </Points>
            </asp:Series>
            <asp:Series Legend="Legend1" Name="Item2" ChartArea="ChartArea1" IsValueShownAsLabel="True">
                <Points>
                    <asp:DataPoint XValue="2008" YValues="98" />
                    <asp:DataPoint XValue="2009" YValues="78" />
                </Points>
            </asp:Series>
            <asp:Series Legend="Legend1" Name="Item3" ChartArea="ChartArea1" IsValueShownAsLabel="True">
                <Points>
                    <asp:DataPoint XValue="2008" YValues="74" />
                </Points>
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
                <AxisY Minimum="0" Maximum="120">
                </AxisY>

            </asp:ChartArea>
        </ChartAreas>
        <Legends>
            <asp:Legend Name="Legend1">
            </asp:Legend>
        </Legends>
        <Titles>
            <asp:Title Name="test 1">
            </asp:Title>
        </Titles>
    </asp:Chart>

Open in new window

0
 
SybuxAuthor Commented:
Ok thanks for your return but is there a way that the code should use the sql query instead as you should imagine, the example is not the reality of my datas !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.