1

这是我的数据示例:
嗨,我是第一次使用 JQPlot,并且在 x 轴上显示月份名称时遇到了困难。

var s1 = [[1, 782751.00], [2, 112592.00], [3, 1350924.00], [4, 648777.00], [5, 725266.00], [6, 358824.00]]

var s2 = [[1, 16], [2, 20], [3, 22], [4, 20], [5, 21], [6, 10]]

var ticks = [1,2,3,4,5,6,7,8]

此处,1,2,3...等表示月份的序列号(如 1 表示 1 月,2 表示 2 月...)

目前它正在显示这些数字......但我需要将其显示为 jan、feb、mar、apr 等。

我已经尝试DATEPART(MONTH,CreatedDate) AS valueCONVERT(char(3), CreatedDate, 0)查询,但是图表没有显示出来……非常感谢您的帮助。


看起来很简单:| :)

进行更改以获得

var ticks = ['January','February','March','April','May'......] 

询问:

 SET DATEFORMAT DMY; 
                        SELECT value FROM
                        ( 
                        SELECT  DISTINCT CONVERT(char(3), CreatedDate, 100) as value,DATEPART(MONTH,CreatedDate) AS Sl
                        FROM SER_TB_JobInfo
                        WHERE CreatedDate BETWEEN DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0) AND GETDATE() ) A ORDER BY Sl
4

1 回答 1

1

您可以使用某种“int to month”翻译器在 javascript 端进行翻译:

//Ticks you actually have
var ticks = [1,2,3,4,5,6,7,8];
//Translator array to do conversion from integer to month
var translator = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

for(var i = 0; i < ticks.length; ++i){
 ticks[i] = translator[i];   
}

蜱现在包含["January", "February", "March", "April", "May", "June", "July", "August"]

于 2013-08-19T06:09:20.473 回答