2011-04-02 69 views

回答

1

現在,有沒有辦法做到這一點。

0

我不是很確定你是問什麼,但我採取的就是這個...

這將顯示帶有圖表的頁面。當你點擊圖表時,它會打開一個新圖表。非常基本,但也許足以玩弄。

把這個在你的控制器:

public ActionResult GetRainfallChart() 
    { 
     var key = new Chart(width: 600, height: 400) 
      .AddSeries(
       chartType: "bar", 
       legend: "Chart", 
       xValue: new[] { "Mon", "Tue", "Wed", "Thu", "Fri" }, 
       yValues: new[] { "23", "12", "13", "42", "22" }) 
      .Write(); 

     return null; 
    } 

    public ActionResult GetRainfallChart2() 
    { 
     var key = new Chart(width: 600, height: 400) 
      .AddSeries(
       chartType: "pie", 
       legend: "Another chart", 
       xValue: new[] { "Mon", "Tue", "Wed", "Thu", "Fri" }, 
       yValues: new[] { "23", "12", "13", "42", "22" }) 
      .Write(); 

     return null; 
    } 

這對於您的觀點:

<!DOCTYPE html> 
<html> 
<head> 
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script> 
    <script> 
     $(function() { 
      $("#dialog").dialog({ 
       autoOpen: false 
      }); 

      $("#chart").click(function() { 
       $("#dialog").dialog("open"); 
       return false; 
      }); 
     }); 
    </script> 
</head> 

<body> 

    <img id="chart" src="/Home/GetRainfallChart" alt="Chart tooltip" /> 

    <div id="dialog"> 
     <img src="/Home/GetRainfallChart2" /> 
    </div> 

</body> 
</html> 
+0

我必須顯示工具提示的意思,如果用戶鼠標在星期一在圖表中它應該顯示23在你的例子和12爲星期二。 – Brij 2011-05-24 10:05:59

+0

gotcha ...因爲這些圖表呈現爲圖像,我不認爲這可以輕鬆完成。你可以嘗試並在其上放置一個圖像映射,但我認爲這不值得付出努力。你可以嘗試一個jQuery圖表產品,例如。 http://plugins.jquery.com/project/gchart或http://www.jqplot.com/(我以前沒有用過這些,但是從我所能看到的,它們是免費選項) – Beno 2011-05-24 21:30:22