2012-06-28 50 views
4

我想在我的图表中显示的月/年,但与x轴标签的错误:jQuery的海军报:在x轴上reapeating标签

enter image description here

有四月2012年3次(以及5月和6月)。

下面是代码

function showGraph() { 
     var data = [ 
      { label : "Odmeny", data: [ [(new Date('2012/04/01')).getTime(), 10], [(new Date('2012/05/01')).getTime(), 10], [(new Date('2012/06/01')).getTime(), 10] ] }, 
      { label : "Koeficienty", data: [ [(new Date('2012/04/01')).getTime(), 11], [(new Date('2012/05/01')).getTime(), 13], [(new Date('2012/06/01')).getTime(), 16], [(new Date('2012/07/01')).getTime(), 12] ] } 
     ]; 
     var options = { 
       xaxes: [{ 
          mode: "time", 
          timeformat: "%b %y", 
          monthNames: ["jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec"] 
         }], 
         yaxes: [ { 
            min: 0 
           } ], 
         series: { 
          lines: { 
           show: true, 
           fill: null 
          }, 
          points: { 
           show: true, 
           radius: 3, 
           lineWidth: 2, 
           fill: true, 
           fillColor: "#ffffff", 
           symbol: "circle" 
          } 
         }, 
         grid: { hoverable: true, clickable: true } 
     }; 

     $.plot($("#placeholder"), data, options); 
    } 
+0

您正在使用什么版本的海军报的?它是Github主分支吗? – DNS

+0

那么,有一些信息:jQuery的JavaScript绘图库,v。0.7,和jQuery的插件,用于处理颜色,版本1.1。 ...不,它不是来自Github的人 –

+0

你可以试试Github上的那个吗?它是实验性的,并且打破了一些东西,但是我们对时间支持做了很多改进;我想知道你看到的问题是否可以解决。如果你确实尝试过,请记住,时间支持已被移入插件中,所以你需要包含额外的.js文件。 – DNS

回答

0

工作代码(没有minThickSize):

var options = { 
      xaxes: [{ 
         mode: "time", 
         timeformat: "%b %y", 
         monthNames: ["jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec"] 
        }], 
        yaxes: [ { 
           min: 0 
          } ], 
        series: { 
         lines: { 
          show: true, 
          fill: null 
         }, 
         points: { 
          show: true, 
          radius: 3, 
          lineWidth: 2, 
          fill: true, 
          fillColor: "#ffffff", 
          symbol: "circle" 
         } 
        }, 
        grid: { hoverable: true, clickable: true } 
    }; 
1

在x轴选项,设置:

minTickSize = [1, "month"] 

现在所发生的事情是,海军报自然尝试生成蜱每月一次不止,然后表现为同一个月,由于你的格式字符串。

+0

抱歉,迟到的回应,但它似乎现在工作,我没有改变任何东西。感谢帮助 –

0
var options = { 
    lines: { show: true }, 
    points: { show: true }, 
    xaxis: { mode: "time", 
    timeformat: "%m/%y", 
    minTickSize: [1, "day"], 
    tickSize: [1, "month"]} 
    };