option = {
ToolTip: {
Trigger: ' Axis ',
Axispointer: {//Axis indicator, axis trigger valid
Type: ' Shadow '//default is line, Optional: ' Lines ' | ' Shadow '
}
},
Legend: {
data:[' Bar 1 ', ' Bar 2 ', ' Bar 3 ',
Selectedmode:false
},
Toolbox: {
Show:true,
Orient: ' Vertical ',
x: ' Right ',
Y: ' Center ',
Feature: {
Mark: {Show:true},
DataView: {show:true, readonly:false},
Magictype: {show:true, type: [' line ', ' Bar ', ' stack ', ' tiled '},
Restore: {show:true},
Saveasimage: {show:true}
}
},
Calculable:true,
Xaxis: [
{
Type: ' Category ',
Data: [' One ', ' two ', ' three ', ' four ', ' V ',]
}
],
YAxis: [
{
Type: ' Value '
}
],
Series: [
{
Name: ' Bar 1 ',
Type: ' Bar ',
Stack: ' Bars ',
DATA:[220, 232, 201, 234, 190],
itemstyle:{
Normal
{
barborderradius:0,
}
}
},
{
Name: ' Bar 2 ',
Type: ' Bar ',
Stack: ' Bars ',
data:[220, 182, 191, 234, 290],
itemstyle:{
Normal
{
barborderradius:0,
}
}
},
{
Name: ' Bar 3 ',
Type: ' Bar ',
Stack: ' Bars ',
DATA:[150, 232, 201, 154, 190],
itemstyle:{
Normal
{
Barborderradius: [5, 5, 0, 0],
label:{
Show:true,
Position: ' Top ',
Formatter:function (params) {
Calculate Total Value
var name = Params.name;
var index; X-axis sequence order
for (var i = 0; i < option.xaxis[0].data.length; i++) {
if (name = = Option.xaxis[0].data[i]) {
index = i;
Break
}
}
var total = 0;
for (var i = 0; i < option.series.length; i++) {
if (Option.series[i].stack = = Params.series.stack) {
Total + = Option.series[i].data[index];
}
}
return total;
},
TextStyle: {
Color: ' Red '
}
}
}
}
}
]
};
Echart Display totals on top