I want to present some condensed data to the user using the Chart
component.
SQL (C# / Oracle):
SELECT c.date, c.approved, count(distinct c.f1) amt_c, count(b.f1) amt_b, sum(b.value) sum_values
FROM contracts c
JOIN bens b ON c.ben_id = b.id
WHERE :YearMonth = to_char(c.date,'YYYYMM') AND NOT c.approved = 'REJECTED'
GROUP BY c.date, c.approved
ORDER BY c.date
I have this SQL in a method that passes a DataSet to the ObjectDataSource in the .aspx page (The approved
field can have 3 values: REJECTED, APPROVED and PENDING).
Chart in .aspx page:
<asp:Chart ID="Chart1" runat="server" DataSourceID="RelatorioDataSource"
Width="700px" Compression="10" Palette="Chocolate">
<Series>
<asp:Series Name="Contracts" XValueMember="date"
YValueMembers="amt_c" IsXValueIndexed="False"
XValueType="DateTime" IsValueShownAsLabel="True" BorderDashStyle="DashDot"
CustomProperties="DrawingStyle=Emboss, EmptyPointValue=Zero, DrawSideBySide=True"
YValuesPerPoint="4">
</asp:Series>
<asp:Series BorderDashStyle="DashDot" ChartArea="ChartArea1"
CustomProperties="DrawingStyle=Emboss, EmptyPointValue=Zero, DrawSideBySide=True"
IsValueShownAsLabel="True" Name="Bens"
XValueMember="date" XValueType="DateTime"
YValueMembers="amt_b" YValuesPerPoint="4">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
I want to show the numbers of approved/pending contracts/bens for each day (4 bars), but the chart shows only two columns.
Create a group for each series..
example:
chart1.series[0]["StackedGroupName"] = "group1";
Solved by creating an object
relatorio
to hold the returned data (instead of the DataSet), filtering the results using LINQ to Objects, and adding the series programmatically in codeBehind.Creating Legends
Creating series in a loop
DataBinding series