Trim long names in charts
Change-Id: If55263072fe0811c27dfb1f58f65987f9612bdf0 Closes-Bug: #1453966
This commit is contained in:
parent
c2b975bd6f
commit
d0d6abb5f8
@ -15,6 +15,12 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
String.prototype.trunc =
|
||||||
|
function (n) {
|
||||||
|
if (this.length <= n) return this;
|
||||||
|
return this.substr(0, this.substr(0, n).lastIndexOf(' ')) + "…";
|
||||||
|
};
|
||||||
|
|
||||||
function _createTimeline(data) {
|
function _createTimeline(data) {
|
||||||
var plot = $.jqplot('timeline', data, {
|
var plot = $.jqplot('timeline', data, {
|
||||||
gridPadding: {
|
gridPadding: {
|
||||||
@ -108,7 +114,7 @@ function renderTableAndChart(url, container_id, table_id, chart_id, link_param,
|
|||||||
|
|
||||||
for (i = 0; i < data.length; i++) {
|
for (i = 0; i < data.length; i++) {
|
||||||
if (i < limit - 1) {
|
if (i < limit - 1) {
|
||||||
chartData.push([data[i].name, data[i].metric]);
|
chartData.push([data[i].name.trunc(30), data[i].metric]);
|
||||||
} else {
|
} else {
|
||||||
aggregate += data[i].metric;
|
aggregate += data[i].metric;
|
||||||
}
|
}
|
||||||
@ -131,7 +137,7 @@ function renderTableAndChart(url, container_id, table_id, chart_id, link_param,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i == limit) {
|
if (i == limit) {
|
||||||
chartData.push([data[i - 1].name, data[i - 1].metric]);
|
chartData.push([data[i - 1].name.trunc(30), data[i - 1].metric]);
|
||||||
} else if (i > limit) {
|
} else if (i > limit) {
|
||||||
chartData.push(["others", aggregate]);
|
chartData.push(["others", aggregate]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user