JS Line Chart

Source: Internet
Author: User
Tags call back

JS Line Chart

Echarts Line chart. Need to introduce: echarts.min.js

<script src= "${ctxstatic}/common/echarts.min.js" charset= "Utf-8" type= "Text/javascript" ></script>

JS Call back-end method, get the data

map<string, object> map = new hashmap<string, object> ();

for (Integer i = 0; i < i++) {

Boolean isexit = false;

String fixindex = "";

if (I < 10) {

Fixindex = "0" + i;

} else {

Fixindex = i.ToString ();

}

For (map<string, object> spmap:list) {

String hour = Spmap.get ("Hour_remark"). toString (). substring (11);

if (Hour.equals (Fixindex)) {

Failcount.add (Integer.valueof (Spmap.get ("Fail_count"). ToString ()));

Isexit = true;

Continue

}

}

if (!isexit) {

Failcount.add (0);

}

}

map<string, object> failcountmap = new hashmap<string, object> ();

Failcountmap.put ("name", "Number of failures");

Failcountmap.put ("Data", failcount);

Allinfo.add (FAILCOUNTMAP);

Map.put ("Data", allinfo);

* Failcountmap : {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= number of failures}

* allinfo : [{data=[0, 0, 0, 0, 0, 0, 0, 0,, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= commit quantity}, {D ata=[0, 0, 0, 0, 0, 0, 0, 0,, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], Name= issued quantity}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= number of successes}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= unknown quantity}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= number of failures} ]

* map : {data=[{data=[0, 0, 0, 0, 0, 0, 0, 0,, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= commit quantity}, {D ata=[0, 0, 0, 0, 0, 0, 0, 0,, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], Name= issued quantity}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= number of successes}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= unknown quantity}, {data=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], name= number of failures} ]}

-----------------------------------JS-----------------------------------------

$ (function () {

$.get ("${ctx}/domesticsms/sendstatisticshour/list?createtime=" +$ ("#createtime"). Val (), function (data) {

var serie = [];

var datatitle = [];

$.each (Data.data, function (i, v) {

var item = {

Name:v.name,

Type: ' line ',

Smooth:true,//smooth, can make line chart smooth

ItemStyle: {normal: {areastyle: {color:red;}},//You can set the shadow color under the line chart.

Data:v.data

}

Serie.push (item);

Datatitle.push (V.name);

});

var mychart = echarts.init (document.getElementById (' Footerdiv_div '));

var option = {

ToolTip: {

Trigger: ' axis '

},

Legend: {

Data:datatitle,

selected:{//sets whether the line chart shows Name:boolean by default,

' Quantity issued ': true,

' Success ': false,

' Failed ': false,

' Unknown ': false

}

},

Grid: {

Left: ' 3% ',

Right: ' 4% ',

Bottom: ' 3% ',

Containlabel:true

},

Toolbox: {

Feature: {

Saveasimage: {}

}

},

Xaxis: {

Type: ' Category ',

Boundarygap:false,

Splitline: {Show:false},//x-axis each point corresponds to a vertical line, whether it is displayed.

Data: [' 00 ', ' 01 ', ' 02 ', ' 03 ', ' 04 ', ' 05 ', ' 06 ', ' 07 ', ' 08 ', ' 09 ', ' 10 ', ' 11 ', ' 12 ', ' 13 ', ' 14 ', ' 15 ', ' 16 ', ' 19 ', ' 20 ', ' 21 ', ' 22 ', ' 23 ']

},

YAxis: {

Type: ' Value '

},

Series:serie

};

mychart.setoption (option);

})

})

JS Line Chart

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.