Using ECharts3.0 to draw stacked bar charts based on the SPRINGMVC framework (next)

Source: Internet
Author: User

<Scripttype= "Text/javascript">$ (). Ready (function() {            varMyChart=Echarts.init (document.getElementById ('Main')); //Chart Display tip informationmychart.showloading (); //Define Chart Optionsoption={tooltip: {trigger:'Axis', Axispointer: {//axis indicator, axis trigger validType:'Shadow' //The default is straight line, optional: ' Lines ' | ' Shadow '}}, Legend: {data: []}, Grid: {left:'3%', right:'4%', bottom:'3%', Containlabel:true}, Xaxis: {type:'value'}, YAxis: {type:'category', data: []}, Series: []}; //getting data through Ajax$.ajax ({type:"Post", Async:false, //Synchronous ExecutionURL:"showechartfoldbar.action", DataType:"JSON", //The returned data is in JSON formSuccess:function(Result) {if(Result) {//assigns the returned category and series objects to the category and series within the options object                        //because Xaxis is an array here needs to be the form of xaxis[i]Option.legend.data=Result.legend; Option.yAxis.data=result.category; varSerisdata=result.series[0].data; vardatas= [];  for ( varI= 0; I<serisdata.length; I++) {Datas.push ({name:serisdata[i].name,                                Type:serisdata[i].type, Stack:serisdata[i].stack, Label: {normal: {show:true, Position:'Insideright'}}, Data:serisdat                        A[i].data,}); } option.series=datas;                        Mychart.hideloading ();                    mychart.setoption (option); }}, Error:function(errormsg) {alert ("Chart request data failed!");        }            });    }); </Script>
@RequestMapping ("/showechartfoldbar") @ResponseBody Publicechartdata Foldbardata () {List<String> legend =NewArraylist<string>(); List<Visit> vis1 = visitbiz.findbycondition (NewVisit (NULL, "Monday",NULL,NULL));  for(Visit visit:vis1) {Legend.add (Visit.getname ()); } List<String> category =NewArraylist<string>(); List<Visit> Vis2 = visitbiz.findbycondition (NewVisit (NULL,NULL,NULL, "Mail Marketing"));  for(Visit visit:vis2) {Category.add (Visit.getweek ()); } List<Map> Serisdata=NewArraylist<map>(); List<String> name =Visitbiz.selectname ();  for(String str:name) {map map=NewHashMap (); Map.put ("Name", str); List<Visit> lis = Visitbiz.findbycondition (NewVisit (NULL,NULL,NULL, str)); List<Long> Data=NewArraylist<long>();  for(Visit visit:lis) {Data.add (Visit.getcount ()); } map.put ("Data", data); Map.put ("Type", "Bar"); Map.put ("Stack", "Total");        Serisdata.add (map); } List<Series> Series =NewArraylist<series> ();//OrdinateSeries.add (NewSeries (NULL,NULL, Serisdata)); Echartdata Data=NewEchartdata (legend,category, series); returndata; }
 Public class Visit {    private  Integer ID;     Private String week;     Private Long count;     Private String name;

Using ECharts3.0 to draw stacked bar charts based on the SPRINGMVC framework (next)

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.