This repository was archived by the owner on Dec 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartDataQuery.cshtml
More file actions
56 lines (42 loc) · 1.51 KB
/
ChartDataQuery.cshtml
File metadata and controls
56 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@{
var db = Database.Open("StarterSite");
//Get the rows of UserID's into an arraw
var userData = db.Query("SELECT UserId FROM UserProfile");
var postData = db.Query("SELECT PostId FROM ForumPosts");
//var data =db.Query("SELECT Product, Price FROM Product");
// convert the db query object to an array (in order to get the Length)
var numUsers = userData.ToArray();
var numPosts = postData.ToArray();
//Create the chart
var profilesChart = new Chart(width:800, height:600, theme:ChartTheme.Blue);
//var myChart = new Chart(width:600,height:400,theme:ChartTheme.Vanilla3D);
profilesChart.AddTitle("Number of Forum Users");
//myChart.AddTitle("Product Sales");
//profilesChart.DataBindTable(dataSource:numUsers.Length, xField:data.);
profilesChart.AddSeries(name:"Users",
xValue:new[]{"Number of Users", "Number of Posts"},
yValues:new[]{numUsers.Length, numPosts.Length});
//myChart.DataBindTable(dataSource:data,xField:"Product");
profilesChart.Write();
//myChart.Write();
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<!-- Testing output from various variables for the chart above
<p>numUsers array length: @numUsers.Length</p>
<p>numPosts array Length: @numPosts.Length</p>
<table>
<tbody>
@foreach(var row in numUsers) {
<tr><td>@row.UserId</td></tr>
}
</tbody>
</table>
-->
</body>
</html>