Notes for using the EChart report plug-in (1)

Source: Internet
Author: User

Report plug-in Echart


Java class

Package com. spring. controller; import java. io. IOException; import java. util. arrays; import java. util. date; import java. util. list; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import net. sf. json. JSONArray; import org. springframework. stereotype. controller; import org. springframework. web. bind. annotation. requestMapping; import org. springframework. web. bind. annotation. requestMethod; import org. springframework. web. servlet. modelAndView; @ Controllerpublic class EchartController {/*** static Echart report page */@ RequestMapping (value = "user/echart", method = {RequestMethod. POST, RequestMethod. GET}) public ModelAndView PostJsonTest (HttpServletRequest request, HttpServletResponse response) throws IOException {ModelAndView mav = new ModelAndView (); mav. addObject ("time", new Date (); mav. setViewName ("echart/echart"); return mav;}/*** dynamic Echart report page */@ RequestMapping (value = "user/echart2", method = {RequestMethod. POST, RequestMethod. GET}) public ModelAndView dynamicEchart (HttpServletRequest request, HttpServletResponse response) throws IOException {ModelAndView mav = new ModelAndView (); String str [] = {"shirt 2", "sweater 2 ", "chiffon shirt 2", "pants 2", "high heels 2", "so 2", "nickname"}; float bar [] = {15, 28, 41, 45, 56,120, 89 }; List <String> category = Arrays. asList (str); // converts an array to listmav. addObject ("time", new Date (); mav. addObject ("listData", category); // listmav. addObject ("array", str); // array mav. addObject ("jsonArray", JSONArray. fromObject (str); // convert to a json array mav. addObject ("jsonList", JSONArray. fromObject (category); // convert to a json array mav. addObject ("jsonInt", JSONArray. fromObject (bar); // convert to a json array mav. setViewName ("echart/dynamicEchart"); return mav ;}}

Static Page:

<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> 

Dynamic page:

<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> 

Run:




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.