c#-Line chart-read data from data difficulties

Source: Internet
Author: User

First come to Zhang:

View section:

@{Viewbag.title="Home Page"; Layout=NULL; stringDate1 =""; stringDate2 =""; if(viewbag.date1!=NULL) {date1=viewbag.date1; }    if(Viewbag.date2! =NULL) {Date2=Viewbag.date2; }}<link href="~/content/jquery-ui.css"Rel="stylesheet"/><script src="~/scripts/jquery-1.10.2.min.js"></script><script src="~/scripts/jquery-ui.js"></script><script src="~/scripts/jquery.ui.datepicker-zh-cn.js"></script>@*<script src="~/scripts/jquery.easyui.min.js"></script>*@<script src="~/scripts/echarts.min.js"></script><script>$ (function () {$ ("#startdate"). DatePicker (); $("#enddate"). DatePicker (); });</script><div> <form method="Post"action="/home/index"> <label> Start date </label><input name="StartDate"Id="StartDate"Value="@date1"> <label> End Date </label><input name="EndDate"Id="EndDate"Value="@date2"> <input type="Submit"Value="Enquiry"> </form></div><div id="Main"style="width:900px;height:400px;margin-top:100px"></div><script type="Text/javascript">//Initializes a Echarts instance based on the prepared Dom    varMyChart = Echarts.init (document.getElementById ('Main')); varoption ={title: {text:'inquire about the usage statistics of the room'}, tooltip: {}, Legend: {data: ['number of uses']}, Xaxis: {data: @MvcHtmlString. Create (Viewbag.datelist),}, YAxis: {}, Series: [{name:'number of', type:' Line', Data: @ViewBag. Countlist,}]       }; mychart.setoption (option);</script>

Controller section:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;usingecharts Dynamic Data. ADO;usingNewtonsoft.json;namespaceecharts Dynamic Data. controllers{ Public classHomecontroller:controller {procuracyroom_testentities db;  PublicActionResult Index () {returnView (); } [HttpPost] [ActionName ("Index")]         PublicActionResult Indexpost () {stringDate1 = request.form["StartDate"]; Viewbag.date1= Date1;//Start Time            stringDate2 = request.form["EndDate"]; Viewbag.date2= Date2;//End TimeDateTime StartDate =Convert.todatetime (date1); DateTime EndDate= Convert.todatetime (date2). AddDays (1); DB=Newprocuracyroom_testentities (); varQ = fromTinchdb. RoomapplicationwhereT.usedate >= startdate && t.usedate < enddate && t.state >0Group T by T.usedate into GSelect New{date = G.key, Count =g.count ()}; varList =q.tolist (); string[] Datelist = ( fromTinchListSelectt.date.toshortdatestring ()).            ToArray (); strings =Jsonconvert.serializeobject (datelist); Viewbag.datelist=s; int[] Countlist = ( fromTinchListSelectt.count).            ToArray (); stringS1 =Jsonconvert.serializeobject (countlist); Viewbag.countlist=S1; returnView ("Index"); }}}


c#-Line chart-read data from data difficulties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.