Jsf Primefaces:图表和图例位置

Jsf Primefaces:图表和图例位置,jsf,primefaces,charts,Jsf,Primefaces,Charts,我正在使用Primefaces制作一个非常基本的堆叠条形图。图表本身似乎构建得很好。但是,图例被放置在图表数据上。我知道您可以将图例移动到任何指南针序号(n、s、w、e、se、sw、ne、nw),但实际上我想将其从数据中移除 获取它的代码: <p:barChart id="stackedKWH" value="#{kwhSalesBeanManager.kwhSalesChart}" legendPosition="e" style="height:300px;width:800px"

我正在使用Primefaces制作一个非常基本的堆叠条形图。图表本身似乎构建得很好。但是,图例被放置在图表数据上。我知道您可以将图例移动到任何指南针序号(n、s、w、e、se、sw、ne、nw),但实际上我想将其从数据中移除

获取它的代码:

 <p:barChart id="stackedKWH" value="#{kwhSalesBeanManager.kwhSalesChart}" legendPosition="e" style="height:300px;width:800px" title="kWh Sales by Type" stacked="true" barMargin="10" min="0" max="125000000" />

以及它目前的样子。希望将该图例从图表中移到右侧


看起来您应该为此使用javascript。 诸如此类:

var legend = $('table.jqplot-table-legend')[0];
legend.setAttribute('style', 'position: absolute; z-index: 3; right: -100px; top: 25px;');

我在这个页面上对它进行了测试:

看起来您应该为此使用javascript。 诸如此类:

var legend = $('table.jqplot-table-legend')[0];
legend.setAttribute('style', 'position: absolute; z-index: 3; right: -100px; top: 25px;');
我在这个页面上测试了它:

尝试添加以下内容:

function extLegend() 
{
    this.cfg.legend= {
        show: true,
        location: 's',
        placement: 'outsideGrid'
    };
}
并将其添加到
条形图
组件中:

 extender="extLegend"
尝试添加以下内容:

function extLegend() 
{
    this.cfg.legend= {
        show: true,
        location: 's',
        placement: 'outsideGrid'
    };
}
并将其添加到
条形图
组件中:

 extender="extLegend"

现在,最好的解决方案是在图表模型上定义placemant:

...
 modelChart.setLegendPlacement(LegendPlacement.OUTSIDE);
...

现在,最好的解决方案是在图表模型上定义placemant:

...
 modelChart.setLegendPlacement(LegendPlacement.OUTSIDE);
...

我在primfaces 5.0中找不到“extender”属性。所以我做了lineModel.setExtender(“extLegend”);我在primfaces 5.0中找不到“extender”属性。所以我做了lineModel.setExtender(“extLegend”);