asp.net mvc - DotnetHighcharts ajax load data? -
custom_scripts_graph.js (ajax post)
$.ajax({ type: "post", url: app_base_url + 'graph/_irregularchart', contenttype: 'application/json; charset=utf-8', datatype: "json", data: chartparams, success: function (result) { $("#chart").html(result); }, error: function (xhr, ajaxoptions, thrownerror) { alert(xhr.status); alert(thrownerror); } });
controller
public actionresult _irregularchart(irregularchartparams chartparams) { ienumerable<meterreadingschartdata> irregularchartdata = meterreadingsmanager.getmeterreadingsirregularchartdata(chartparams); series[] series = chartdatamanager.getirregularchartdata(irregularchartdata).toarray(); highcharts chart = new highcharts("irregularchart") .initchart(new chart { defaultseriestype = charttypes.line, zoomtype = zoomtypes.xy, height = 300 }) .setoptions(new globaloptions { global = new global { useutc = false } }) .settitle(new title { text = "başlık" }) .setsubtitle(new subtitle { text = "altbaşlık" }) .setlegend(new legend { layout = layouts.vertical, verticalalign = verticalaligns.top, align = horizontalaligns.right, shadow = true, backgroundcolor = colortranslator.fromhtml("#ffffff"), floating = true }) .setxaxis(new xaxis { type = axistypes.datetime, datetimelabelformats = new datetimelabel { month = "%e. %b", hour = "%h:%m", year = "%y" } }) .setyaxis(new yaxis { title = new yaxistitle { text = "yaxis title" }, labels = new yaxislabels { formatter = @"function() { return this.value; }" } }) .setcredits(new credits { enabled = false }) .settooltip(new tooltip { formatter = "function() { return '<b>'+ this.series.name +'</b><br/>'+ highcharts.dateformat('%e. %b - %h:%m', this.x) +' : <b>'+ highcharts.numberformat(this.y, 2); +'</b>'; }" }) .setseries(series); return partialview(chart); }
chart.cshtml
<script src="@url.content("~/scripts/custom_scripts_graph.js")" type="text/javascript"></script> <div id="chart"> </div>
_irregularchart.cshtml(partial view)
@model dotnet.highcharts.highcharts @model
error :
unexpected token <
all data true. ajax response:
<div id='irregularchart_container'></div> <script type='text/javascript'> highcharts.setoptions({ global: { useutc: false } }); var irregularchart; $(document).ready(function() { irregularchart = new highcharts.chart({ chart: { renderto:'irregularchart_container', defaultseriestype: 'line', height: 300, zoomtype: 'xy' }, credits: { enabled: false }, legend: { align: 'right', backgroundcolor: '#ffffff', floating: true, layout: 'vertical', shadow: true, verticalalign: 'top' }, plotoptions: { line: { linewidth: 3, marker: { enabled: true, states: { hover: { enabled: true, radius: 5 } } }, states: { hover: { linewidth: 3 } } } }, subtitle: { text: 'altbaşlık' }, title: { text: 'başlık' }, tooltip: { formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ highcharts.dateformat('%e. %b - %h:%m', this.x) +' : <b>'+ highcharts.numberformat(this.y, 2); +'</b>'; } }, xaxis: { datetimelabelformats: { hour: '%h:%m', month: '%e. %b', year: '%y' }, type: 'datetime' }, yaxis: { labels: { formatter: function() { return this.value; } }, title: { text: 'yaxis title' } }, series: [{ data: [[date.parse('03/26/2013 00:00:00'), 219.666666666667], [date.parse('03/26/2013 01:00:00'), 219.333333333333], [date.parse('03/26/2013 02:00:00'), 220], [date.parse('03/26/2013 03:00:00'), 219.666666666667], [date.parse('03/26/2013 04:00:00'), 220], [date.parse('03/26/2013 05:00:00'), 219.333333333333], [date.parse('03/26/2013 06:00:00'), 219], [date.parse('03/26/2013 07:00:00'), 220], [date.parse('03/26/2013 08:00:00'), 219.666666666667], [date.parse('03/26/2013 09:00:00'), 220], [date.parse('03/26/2013 10:00:00'), 220], [date.parse('03/26/2013 11:00:00'), 220], [date.parse('03/26/2013 12:00:00'), 219.666666666667], [date.parse('03/26/2013 13:00:00'), 220], [date.parse('03/26/2013 14:00:00'), 219.5], [date.parse('03/26/2013 15:00:00'), 220], [date.parse('03/26/2013 16:00:00'), 220], [date.parse('03/26/2013 17:00:00'), 220], [date.parse('03/26/2013 18:00:00'), 219.666666666667], [date.parse('03/26/2013 19:00:00'), 220], [date.parse('03/26/2013 20:00:00'), 219.666666666667], [date.parse('03/26/2013 21:00:00'), 219], [date.parse('03/26/2013 22:00:00'), 219.5], [date.parse('03/26/2013 23:00:00'), 219], [date.parse('03/27/2013 00:00:00'), 219.5], [date.parse('03/27/2013 01:00:00'), 220], [date.parse('03/27/2013 02:00:00'), 220], [date.parse('03/27/2013 03:00:00'), 220], [date.parse('03/27/2013 04:00:00'), 219.666666666667], [date.parse('03/27/2013 05:00:00'), 219.5], [date.parse('03/27/2013 06:00:00'), 219.5], [date.parse('03/27/2013 07:00:00'), 220], [date.parse('03/27/2013 08:00:00'), 219.666666666667], [date.parse('03/27/2013 09:00:00'), 220], [date.parse('03/27/2013 10:00:00'), 220], [date.parse('03/27/2013 11:00:00'), 220], [date.parse('03/27/2013 12:00:00'), 219.5], [date.parse('03/27/2013 13:00:00'), 220], [date.parse('03/27/2013 14:00:00'), 219.666666666667], [date.parse('03/27/2013 15:00:00'), 220], [date.parse('03/27/2013 16:00:00'), 219.666666666667], [date.parse('03/27/2013 17:00:00'), 220], [date.parse('03/27/2013 18:00:00'), 220], [date.parse('03/27/2013 19:00:00'), 220], [date.parse('03/27/2013 20:00:00'), 219.666666666667], [date.parse('03/27/2013 21:00:00'), 219.666666666667], [date.parse('03/27/2013 22:00:00'), 220], [date.parse('03/27/2013 23:00:00'), 219.333333333333], [date.parse('03/28/2013 00:00:00'), 219], [date.parse('03/28/2013 01:00:00'), 219.333333333333], [date.parse('03/28/2013 02:00:00'), 220], [date.parse('03/28/2013 03:00:00'), 219.333333333333], [date.parse('03/28/2013 04:00:00'), 219.666666666667], [date.parse('03/28/2013 05:00:00'), 220], [date.parse('03/28/2013 06:00:00'), 219], [date.parse('03/28/2013 07:00:00'), 219.5], [date.parse('03/28/2013 08:00:00'), 220], [date.parse('03/28/2013 09:00:00'), 220], [date.parse('03/28/2013 10:00:00'), 220], [date.parse('03/28/2013 11:00:00'), 219.666666666667], [date.parse('03/28/2013 12:00:00'), 219], [date.parse('03/28/2013 13:00:00'), 220], [date.parse('03/28/2013 14:00:00'), 219.5], [date.parse('03/28/2013 17:00:00'), 219.5], [date.parse('03/28/2013 18:00:00'), 219.666666666667], [date.parse('03/28/2013 19:00:00'), 220], [date.parse('03/28/2013 20:00:00'), 219], [date.parse('03/28/2013 21:00:00'), 220], [date.parse('03/28/2013 22:00:00'), 219], [date.parse('03/28/2013 23:00:00'), 219.333333333333], [date.parse('03/29/2013 00:00:00'), 219.5], [date.parse('03/29/2013 03:00:00'), 220], [date.parse('03/29/2013 04:00:00'), 220], [date.parse('03/29/2013 05:00:00'), 220], [date.parse('03/29/2013 07:00:00'), 219], [date.parse('03/29/2013 08:00:00'), 219.5], [date.parse('03/29/2013 09:00:00'), 220], [date.parse('03/29/2013 10:00:00'), 220], [date.parse('03/29/2013 11:00:00'), 219.5], [date.parse('03/29/2013 12:00:00'), 219], [date.parse('03/29/2013 13:00:00'), 219.5], [date.parse('03/29/2013 14:00:00'), 220], [date.parse('03/29/2013 15:00:00'), 219.5], [date.parse('03/29/2013 17:00:00'), 220], [date.parse('03/29/2013 18:00:00'), 219.666666666667], [date.parse('03/29/2013 19:00:00'), 220], [date.parse('03/29/2013 20:00:00'), 220], [date.parse('03/29/2013 21:00:00'), 219.5], [date.parse('03/29/2013 22:00:00'), 219.333333333333], [date.parse('03/29/2013 23:00:00'), 219.666666666667], [date.parse('03/30/2013 00:00:00'), 220], [date.parse('03/30/2013 01:00:00'), 219.666666666667], [date.parse('03/30/2013 02:00:00'), 219], [date.parse('03/30/2013 03:00:00'), 219.333333333333], [date.parse('03/30/2013 04:00:00'), 219.333333333333], [date.parse('03/30/2013 05:00:00'), 219.5], [date.parse('03/30/2013 06:00:00'), 219], [date.parse('03/30/2013 07:00:00'), 220], [date.parse('03/30/2013 08:00:00'), 219.333333333333], [date.parse('03/30/2013 09:00:00'), 220], [date.parse('03/30/2013 10:00:00'), 219.666666666667], [date.parse('03/30/2013 11:00:00'), 219.5], [date.parse('03/30/2013 12:00:00'), 220], [date.parse('03/30/2013 13:00:00'), 219.5], [date.parse('03/30/2013 14:00:00'), 220], [date.parse('03/30/2013 15:00:00'), 219.5], [date.parse('03/30/2013 16:00:00'), 219.5], [date.parse('03/30/2013 17:00:00'), 219.333333333333], [date.parse('03/30/2013 18:00:00'), 220], [date.parse('03/30/2013 19:00:00'), 219.5], [date.parse('03/30/2013 20:00:00'), 220], [date.parse('03/30/2013 21:00:00'), 219], [date.parse('03/30/2013 22:00:00'), 219.5], [date.parse('03/30/2013 23:00:00'), 219.666666666667], [date.parse('03/31/2013 00:00:00'), 219.5], [date.parse('03/31/2013 01:00:00'), 220], [date.parse('03/31/2013 02:00:00'), 219], [date.parse('03/31/2013 04:00:00'), 219.666666666667], [date.parse('03/31/2013 05:00:00'), 218.5], [date.parse('03/31/2013 06:00:00'), 219.666666666667], [date.parse('03/31/2013 07:00:00'), 219.666666666667], [date.parse('03/31/2013 08:00:00'), 218], [date.parse('03/31/2013 09:00:00'), 219.333333333333], [date.parse('03/31/2013 10:00:00'), 219.5], [date.parse('03/31/2013 11:00:00'), 219.666666666667], [date.parse('03/31/2013 12:00:00'), 219.5], [date.parse('03/31/2013 13:00:00'), 219.333333333333], [date.parse('03/31/2013 14:00:00'), 220], [date.parse('03/31/2013 15:00:00'), 220], [date.parse('03/31/2013 16:00:00'), 219.333333333333], [date.parse('03/31/2013 17:00:00'), 220], [date.parse('03/31/2013 18:00:00'), 219.333333333333], [date.parse('03/31/2013 19:00:00'), 219], [date.parse('03/31/2013 20:00:00'), 219.5], [date.parse('03/31/2013 21:00:00'), 220], [date.parse('03/31/2013 22:00:00'), 219], [date.parse('03/31/2013 23:00:00'), 219.666666666667], [date.parse('04/01/2013 00:00:00'), 220], [date.parse('04/01/2013 01:00:00'), 219.666666666667], [date.parse('04/01/2013 02:00:00'), 220], [date.parse('04/01/2013 04:00:00'), 220], [date.parse('04/01/2013 05:00:00'), 220], [date.parse('04/01/2013 06:00:00'), 219.5], [date.parse('04/01/2013 07:00:00'), 220], [date.parse('04/01/2013 08:00:00'), 219], [date.parse('04/01/2013 09:00:00'), 219.666666666667], [date.parse('04/01/2013 10:00:00'), 220]], name: 'gerilim faz 1 v' }] }); }); </script>
and demo above data , works. removed script tags. think script tags. suggestion this.
thanks...
i removed following line ajax
datatype: "json",
and works, cant understand why? if know reason, explain it?
Comments
Post a Comment