Asp.net MVC project development Statistical Chart echarts background data processing (3), mvcecharts

Source: Internet
Author: User

Asp.net MVC project development Statistical Chart echarts background data processing (3), mvcecharts

The items displayed on the front end are easily modified with corresponding documents. The data transmission method on the back end is what we are most concerned about.

First of all, remember that we use post as the data in one step, so we need to add the [HttpPost] annotation to the method in the background code.

Otherwise, Asynchronization is ineffective.

The code below is used to save time and Name field variables. I use English letters 1, 2, and 3. Don't be surprised.

Public ActionResult GetMarriageList (int areaId, int level) {List <VwAllPersonInfoModel> allPerList = new List <VwAllPersonInfoModel> (); IVwAllPersonInfoService allPerService = LoadService <IVwAllPersonInfoService> (); Dictionary <string, object> json = new Dictionary <string, Object> (); DdlDataSrc ddl = new DdlDataSrc (); DataTable dt = new DataTable (); Criteria c = new Criteria (); stringBuilder sb = new StringBuilder (); ddl. getAllChildAreaIds (sb, areaId); # region puts the obtained data into json int one = 0; int two = 0; int three = 0; int four = 0; if (level = 3) {c. addWhere ("AreaId", areaId); allPerList = allPerService. getAllVwAllPersonInfoModel (c);} else if (level! = 0) {string str = sb. remove (sb. length-1, 1 ). toString (); dt = allPerService. getAllPersonInfoCharts (str, 0, 0); allPerList = (List <VwAllPersonInfoModel>) ModelConvertHelper <VwAllPersonInfoModel>. convertToModel (dt);} if (allPerList. count! = 0) {for (int I = 0; I <allPerList. count; I ++) {switch (allPerList [I]. maticalStatus) // marital status {case 1: ++ one; break; case 2: ++ two; break; case 3: ++ three; break; case 4: ++ four; break;} json. add ("Unmarried", one); json. add ("Married with spouse", two); json. add ("divorce", three); json. add ("zombie", four);} else {json. add ("no data", 1) ;}# endregion return Json (json );}View Code

Here we use Dictionary <string, Object> json = new Dictionary <string, Object> (); the structure of Dictionary is as follows: Dictionary <[key], [value]> provides a fast key-value search method to asynchronously display the input to the statistics graph.

If the data is single-choice, you can use switch for determination. if multiple data is selected, use if for determination. I hope to help you with your feedback and make progress together.

Related Article

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.