获取数组的最后一个值并将其显示在X轴下 [英] Getting the last value of an Array and showing it under X axis

查看:27
本文介绍了获取数组的最后一个值并将其显示在X轴下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var NewdateData[] = [1,2,3,4,5,6,7,8,9,1,2,1,23,45,56]

NewdateData 是根据用户界面中的选择从数据库动态填充的.

This NewdateData is dynamically filled from database depending upon the selection made from the user interface.

我正在使用此 NewdateData 在X轴图表下方显示.

I am using this NewdateData for displaying under the X axis Charts.

我面临的问题是,这些值要到最后才使用,我想在X轴标签下拥有最后一个值.

The issue I am facing is that, the values are not taken till the end , I want to have the last value to have under the X axis Labels.

xaxis: {tickFormatter: function(n)
{
    var k = Math.round(n);
    return NewdateData[k]; 
}

我正在使用 flotr .

推荐答案

您可以使用以下方法获取数组的最后一个值:

You can get the last value of an array with:

NewdateData[NewdateData.length-1];

这篇关于获取数组的最后一个值并将其显示在X轴下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆