FYI, if that is the methodology you are using to access your data, then
you're not using MVC.
I think this is basically what you want to draw the chart:
@{
Layout = null;
var db = Database.Open("HEK");
var data = db.Query("SELECT * FROM VWS where ID > 2200");
// move to a DataTable
DataTable dataTable = new DataTable();
data.copyToDataTable(dataTable);
// create an array of rows
List<string> rows = new List<string>();
rowsList.Add("['nivo Sava', 'RPWS1', 'RPWS2', 'RPWS3']");
foreach(DataRow row in dataTable.rows) {
rowsList.Add("[" + row.item["Datum"] + ", " + row.item["Sava"] + ",
" + row.item["RPWS1"] + ", " + row.item["RPWS2"] + ", " + row.item["RPWS3"]
+ "]");
}
String rows = String.Join(", ", rowsList);
}
<script type='text/javascript' src="http://www.google.com/jsapi"></script>
<script type="text/javascript>
function drawChart () {
var data = google.visualization.arrayToDataTable([@rowsList]);
var chart = new
google.visualization.LineChart(document.getElementById('chart_div');
chart.draw(data, {
height: 350,
width: 900,
title: 'Absolutna kota vode v tesnilni zavesi',
vAxis: {
maxValue: 165.5,
minValue: 159,
title: 'absolutna kota'
}
});
}
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
</script>
<div id="chart_div"></div>
You'll have to test and debug that yourself (as I don't have an ASP.net
environment handy to test that code in right now).
On Monday, February 18, 2013 3:33:16 AM UTC-5, Matevz Uros Pavlic wrote:
>
> Hi,
>
> this is the code that gets the chart from SQL database :
>
> @{
>
> Layout = null;
>
> var db = Database.Open("HEK");
> var data = db.Query("SELECT * FROM VWS where ID > 2200");
>
> var myChart = new Chart(width: 900, height: 350)
> .AddTitle("Absolutna kota vode v tesnilni zavesi")
> .AddSeries("nivo Sava", chartType: "Line", xValue: data, xField:
> "Datum", yValues: data, yFields: "Sava")
> .AddSeries("RPWS1", chartType: "Line", xValue: data, xField:
> "Datum", yValues: data, yFields: "RPWS1")
> .AddSeries("RPWS2", chartType: "Line", xValue: data, xField:
> "Datum", yValues: data, yFields: "RPWS2")
> .AddSeries("RPWS3", chartType: "Line", xValue: data, xField:
> "Datum", yValues: data, yFields: "RPWS3")
>
> .SetYAxis("absolutna kota", 159, 165.5)
>
> .AddLegend()
> .Write();}
>
>
> But this chart is not SVg, it's put in as an image...i'd like to put it in as
> SVG...
>
>
> I'm not sure that's all you need, so please let me know if you need something
> more.
>
>
> regards, m
>
>
>
>
>
>
> On Monday, February 18, 2013 3:19:35 AM UTC+1, asgallant wrote:
>>
>> Can you post the code that outputs the data in a webpage? I'll take a
>> look and see what you might do with it to build a chart with it instead.
>>
>> On Sunday, February 17, 2013 5:48:41 PM UTC-5, Matevz Uros Pavlic wrote:
>>>
>>> Hi,
>>>
>>> I think so to the first answer (using Webmatrix).
>>>
>>> If by "model set" you mean if i can connect to a databse in my server,
>>> yes. Yes i can get data out of sql and show in web page.
>>>
>>> Tnx, m
>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.