我正在使用在不规则位置具有刻度线的flot制作情节,例如一个在100位,一个在155位,一个在230位.Flot能够很容易地将这些位置放在这些位置。
但我想把轴标签放在这些点之间,例如
|--------------|-------|------------------|
blahblah huh metoo
无法弄清楚如何抓住这个。任何sugestions?
由于
答案 0 :(得分:1)
这使用flot的多轴功能为您的标签添加第二个轴:
代码:
$.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。