编辑p:chart中的数据提示位置



我使用的是PrimeFaces6.0,我想在条形图上显示工具提示。我试过像这个例子这样的datatipeditor,它运行得很好。问题是,我可能会使用长文本作为工具提示,而最左边的栏不会像这样显示全文。

我试着用这个代码移动位置。

function toolTip(str, seriesIndex, pointIndex, plot){
var val = plot.data[seriesIndex][pointIndex];
return "<div style='position:relative; left:80px; bottom:15px;'>1aaaaaaaaaaaaaaaaaaaa: " + 
(pointIndex +1) + "<br/>2bbbbbbbbbbbbbbbbbb: " + val + "</div>";
}

文本按照我的设计移动,但盒子仍然像这样。

我本来想使用extender,但在文档页面上我不知道该使用哪个属性,以及如何将数据从bean作为工具提示的文本传递。

知道如何将方框和文本移动到我用datatipeditor设计的位置吗?

内部bean:

CartesianChartModel barModel = new BarChartModel();
barModel.setExtender("myExtender");

然后在我的js中,我使用highlighter中的tooltipContentEditor,下面是代码:

function myExtender(){
this.cfg.highlighter = {
tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) {
var val = plot.data[seriesIndex][pointIndex];
return "this value is: " + val + "<br/>this is a looooooooooooong text";
},
show: true, 
useAxesFormatters: false,
tooltipLocation: 'n'
};
}

结果如下。

最新更新