4
Flot을 사용하여 그래프를 만듭니다. 이 내가 데이터 1, 데이터 2, DATA3, DATA4 flot에서 x 축 레이블을 얻는 방법은 무엇입니까?
function drawSeriesHook(plot, canvascontext, series) {
var ctx = canvascontext,
plotOffset = plot.offset(),
labelText = 'VALUE', // customise this text, maybe to series.label
points = series.datapoints.points,
ps = series.datapoints.pointsize,
xaxis = series.xaxis,
yaxis = series.yaxis,
textWidth, textHeight, textX, textY;
// only draw label for top yellow series
if (series.color === '#F8C095') {
ctx.save();
ctx.translate(plotOffset.left, plotOffset.top);
ctx.lineWidth = series.bars.lineWidth;
ctx.fillStyle = '#000'; // customise the colour here
for (var i = 0; i < points.length; i += ps) {
if (points[i] == null) continue;
textWidth = ctx.measureText(labelText).width; // measure how wide the label will be
textHeight = parseInt(ctx.font); // extract the font size from the context.font string
textX = xaxis.p2c(points[i] + series.bars.barWidth/2) - textWidth/2;
textY = yaxis.p2c(points[i + 1]) - textHeight/2;
ctx.fillText(labelText, textX, textY); // draw the label
}
ctx.restore();
}
}
- 내 drawseriesHook 기능에 내 코드가 있습니다 series.label &를 사용하지 않고 series.color.Currently 난 기능
이 라벨은 모든 틱 레이블을 갖습니다. 개별적으로 라벨을 가져 오는 방법은 무엇입니까? –
@Coder_sLaY : 모두 원하지 않는다면 현재 레이블 만 원하십니까? – scessor
예. 그렇지만 경고 (레이블)를 입력하면 모든 것이 4가됩니다. 첫 번째 만 필요합니다. –