So I have managed to create a graph based on current user data and I am attempting to tidy up the view. So far the view is taking up the whole page and hiding my navbar etc. I have tried to wrap it in div's, body, but cannot get it to work. I am not very good at the html/View part (thats obvious!) and feel as if I'm missing something simple.
This is my controller: (I've removed specific details)
public async Task<ActionResult> DrawChart()
{
var currentUser = await manager.FindByIdAsync(User.Identity.GetUserId());
var data = new List<Data>(db.Data.ToList().Where(d => d.User.Id == currentUser.Id));
string connectionString = @"Data Source";
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
using (SqlCommand command = new SqlCommand("SELECT Required Data FROM Data WHERE User_Id = 'currentUserId'", con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
data.Add(new Data { Xdata = reader.GetDateTime(0), ydata = reader.GetDouble(1) });
}
}
}
return View(workouts);
}
This is my View: (again removed specific details)
@model IEnumerable<MyModel>
@{
ViewBag.Title = "DrawChart";
}
@{
var myChart = new Chart(width: 800, height: 500)
.AddTitle("Insert Title")
.AddSeries(chartType: "Line",
xValue: Model, xField: "XData",
yValues: Model, yFields: "YData")
.Write("png")
.Save("png");
}
I've attempted this suggestion from docs.microsoft: (Which doesn't work)
<!DOCTYPE html>
<html>
<head>
<title>Chart Example</title>
</head>
<body>
<h1>Chart Example</h1>
<p>The following chart is generated by the <em>ChartArrayBasic.cshtml</em> file, but is shown
in this page.</p>
<p><img src="ChartArrayBasic.cshtml" /> </p>
</body>
</html>
How do I fix this view?