2012-07-04 3 views
1

불규칙한 위치에 눈금이 표시된 flot을 사용하여 플롯을 만들고 있습니다. 위치 100에 하나, 위치 155에 하나, 위치 230에 하나. Flot은 해당 위치에 눈금을 쉽게 붙일 수 있습니다.위치 flot xaxis labels

하지만이 두 지점 사이에 축 레이블을 넣고 싶습니다.

|--------------|-------|------------------| 
    blahblah  huh  metoo 

flot을 얻는 방법을 알아낼 수 없습니다. 어떤 설교?

감사

답변

1

이 레이블로 두 번째 축을 추가 FLOT의 여러 축 기능을 사용

enter image description here

코드 :

 $.plot($("#placeholder"), 
     [ { data: [[1,1],[12,12],[45,45],[2,2],[7,7],[90,90],[112,112],[145,145],[87,87],[250,250]]}, 
     { data: [[]], xaxis: 2}], //second empty series 
      { 
       xaxes: [ {ticks:[100,155,230]}, // force tick location 
         {ticks: [50,127.5,192.5], // label locations, center them based on forced tick locations 
         min: 0, max: 250, // set min and max to scale 2nd axis 
         tickFormatter: // return string label instead of number 
          function formatter(val, axis) { 
          if (val == 50) return "blahblah"; 
          else if (val == 127.5) return "huh"; 
          else if (val == 192.5) return "metoo"; 
          else return ""; 
          }} ] 
      });​ 

바이올린 here.