2013-10-18 56 views
-1

我有一個Shield UI ASP.NET MVC,並且正在嘗試使用事件功能。我已經從網站採取SOM的源代碼,並把它放在相應:使用Shield UI ASP.NET MVC事件功能

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <title>@ViewBag.Title</title> 
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> 
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script> 

    <link href="@Url.Content("~/shield-chart.1.2.2-Trial/shield-chart.1.2.2-Trial/css/shield-chart.min.css")" rel="stylesheet" type="text/css" /> 
    <script src="@Url.Content("~/shield-chart.1.2.2-Trial/shield-chart.1.2.2-Trial/js/jquery-1.9.1.min.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/shield-chart.1.2.2-Trial/shield-chart.1.2.2-Trial/js/shield-chart.all.min.js")" type="text/javascript"></script> 

<script type="text/ecmascript"> 
    function HideChart() { 
     document.getElementById("DataSpot").innerHTML = ""; 
    } 
    function chartEventFunction(e) { 
     alert("Chart ID: " + e.target.element.attr("id")); 
    } 
</script> 

,並在我的cshtm文件我有這樣的:

@(Html.ShieldChart() 
    .Events(events => events 
       .SeriesClick("chartEventFunction"))) 


    .Name("chartA") 
    .AxisX(axisX => axisX.Title(title => title.Text("Speed of Wind"))) 
    .AxisY(axisY => axisY.Title(title => title.Text("RainFall Quantities"))) 
    .PrimaryHeader(header => header.Text("Weather - Wind/Precipitation Values")) 
    .Tooltip(tooltip => tooltip.AxisMarkers(axisMarkers => axisMarkers 
     .Enabled(true) 
     .Mode(Shield.Mvc.UI.Chart.TooltipAxisMarkerMode.XY) 
     .Width(1) 
     .ZIndex(3))) 
    .ChartLegend(chartLegend => chartLegend 
     .Align(Shield.Mvc.UI.Chart.Align.Right) 
     .VerticalAlign(Shield.Mvc.UI.Chart.VerticalAlign.Top) 
     .RenderDirection(Shield.Mvc.UI.Chart.Direction.Vertical)) 
    .DataSeries(dataSeries => dataSeries.Scatter() 
     .CollectionAlias("January 2008") 
     .Data(new object[]{ 
      new object[]{16.4, 5.4}, new object[]{21.7, 2}, new object[]{25.4, 3}, new object[]{19, 2}, new object[]{10.9, 1}, new object[]{13.6, 3.2}, new object[]{10.9, 7.4}, new object[]{10.9, 0}, new object[]{10.9, 8.2}, new object[]{16.4, 0}, new object[]{16.4, 1.8}, new object[]{13.6, 0.3}, new object[]{13.6, 0}, new object[]{29.9, 0}, new object[]{27.1, 2.3}, new object[]{16.4, 0}, new object[]{13.6, 3.7}, new object[]{10.9, 5.2}, new object[]{16.4, 6.5}, new object[]{10.9, 0}, new object[]{24.5, 7.1}, new object[]{10.9, 0}, new object[]{8.1, 4.7}, new object[]{19, 0}, new object[]{21.7, 1.8}, new object[]{27.1, 0}, new object[]{24.5, 0}, new object[]{27.1, 0}, new object[]{29.9, 1.5}, new object[]{27.1, 0.8}, new object[]{22.1, 2} 
     })) 
    .DataSeries(dataSeries => dataSeries.Scatter() 
     .CollectionAlias("January 2009") 
     .Data(new object[]{ 
      new object[]{6.4, 13.4}, new object[]{1.7, 11}, new object[]{5.4, 8}, new object[]{9, 17}, new object[]{1.9, 4}, new object[]{3.6, 12.2}, new object[]{1.9, 14.4}, new object[]{1.9, 9}, new object[]{1.9, 13.2}, new object[]{1.4, 7}, new object[]{6.4, 8.8}, new object[]{3.6, 4.3}, new object[]{1.6, 10}, new object[]{9.9, 2}, new object[]{7.1, 15}, new object[]{1.4, 0}, new object[]{3.6, 13.7}, new object[]{1.9, 15.2}, new object[]{6.4, 16.5}, new object[]{0.9, 10}, new object[]{4.5, 17.1}, new object[]{10.9, 10}, new object[]{0.1, 14.7}, new object[]{9, 10}, new object[]{2.7, 11.8}, new object[]{2.1, 10}, new object[]{2.5, 10}, new object[]{27.1, 10}, new object[]{2.9, 11.5}, new object[]{7.1, 10.8}, new object[]{2.1, 12} 
     })) 
    .DataSeries(dataSeries => dataSeries.Scatter() 
     .CollectionAlias("January 2010") 
     .AddToLegend(false) 
     .Data(new object[]{ 
      new object[]{21.7, 3}, new object[]{13.6, 3.5}, new object[]{13.6, 3}, new object[]{29.9, 3}, new object[]{21.7, 20}, new object[]{19, 2}, new object[]{10.9, 3}, new object[]{28, 4}, new object[]{27.1, 0.3}, new object[]{16.4, 4}, new object[]{13.6, 0}, new object[]{19, 5}, new object[]{16.4, 3}, new object[]{24.5, 3}, new object[]{32.6, 3}, new object[]{27.1, 4}, new object[]{13.6, 6}, new object[]{13.6, 8}, new object[]{13.6, 5}, new object[]{10.9, 4}, new object[]{16.4, 0}, new object[]{32.6, 10.3}, new object[]{21.7, 20.8}, new object[]{24.5, 0.8}, new object[]{16.4, 0}, new object[]{21.7, 6.9}, new object[]{13.6, 7.7}, new object[]{16.4, 0}, new object[]{8.1, 0}, new object[]{16.4, 0}, new object[]{16.4, 0} 
     })) 
) 

有一些問題,我認爲是由存在導致函數聲明,我把它放在正確的地方。還有什麼可能是錯的? 還有一件事。對於MVC圖表,我沒有可以獲得(或至少在網站上找到)的可用事件列表。我怎麼能知道事件的完整列表?

回答

1

問題是僅僅語法:

@(Html.ShieldChart() 
.Events(events => events 
      .SeriesClick("chartEventFunction"))) 

具有一個過度)。

它導致後面的代碼被遺漏,可能你在瀏覽器中得到了一個奇怪的輸出。

至於可用事件 - 您可以通過調用IDE中的上下文菜單來查看它們。 但是這裏有一個列表與他們寫下:

Click 
Load 
PointDeselect 
PointSelect 
SeriesClick 
SeriesMouseOut 
SeriesMouseOver 
SeriesMouseVisibilityChane 
Zoom