Setting Shield UI ASP.NET MVC Auto refresh rate

170 Views Asked by At

I am using a Shield UI ASP.NET MVC chart on my page. Here is some of my code:

@(Html.ShieldChart()
.Name("chart5")
.PrimaryHeader(header => header.Text("Profile Hits"))
.Export(false)
.AxisX(axisX => axisX
.CategoricalValues("Jan", "Feb", "Mar", "Apr", "May", "Jun"))
    .AxisY(axisY => axisY.Title(title => title.Text("Profile Hits")))
.DataSeries(dataSeries => dataSeries.Line()
    .CollectionAlias("Total Visits")
    .Data(new object[]{565000, 630400, 743000, 910200, 1170200, 1383000}))
.DataSeries(dataSeries => dataSeries.Bar()
    .CollectionAlias("Unique Visits")
    .Data(new object[]{152000, 234000, 123000, 348000, 167000, 283000}))

var interval = 500;
function reload() {
    window.setTimeout(function () { reload() }, interval);
}
)

I am receiving an error, which I can’t solve. The purpose is to enable the page to reload over intervals that are predefined in a variable.

1

There are 1 best solutions below

0
On BEST ANSWER

You are making a mistake in placing your JS code into the right place. Here is the corrected code:

<input type="text" id="intrvl" value="1200" />
<script type="text/javascript">
    var interval = 500;
    function reload() {
        window.setTimeout(function () { reload() }, interval);
    }
</script>
<script type="text/javascript">    reload();</script>
<p id="DataSpot">
@(Html.ShieldChart()
    .Name("chart5")
    .PrimaryHeader(header => header.Text("Profile Hits"))
    .Export(false)
    .AxisX(axisX => axisX
    .CategoricalValues("Jan", "Feb", "Mar", "Apr", "May", "Jun"))
        .AxisY(axisY => axisY.Title(title => title.Text("Profile Hits")))
    .DataSeries(dataSeries => dataSeries.Line()
        .CollectionAlias("Total Visits")
        .Data(new object[]{565000, 630400, 743000, 910200, 1170200, 1383000}))
    .DataSeries(dataSeries => dataSeries.Bar()
        .CollectionAlias("Unique Visits")
        .Data(new object[]{152000, 234000, 123000, 348000, 167000, 283000}))
)
</p>