Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PrimeFaces:ChartJs堆叠条形图标签移除_Javascript_Java_Primefaces_Chart.js - Fatal编程技术网

Javascript PrimeFaces:ChartJs堆叠条形图标签移除

Javascript PrimeFaces:ChartJs堆叠条形图标签移除,javascript,java,primefaces,chart.js,Javascript,Java,Primefaces,Chart.js,我正在开发一个仪表板,其中有一个带有一些销售代表数据的图表。这是我的代码和图片 //xhtml element: <p:panel header="Oportunidades"> <p:barChart id="graficoOportunidadesRepresentante" model="#{dashboardBean.barModel}" style="width:100%; height:

我正在开发一个仪表板,其中有一个带有一些销售代表数据的图表。这是我的代码和图片

//xhtml element:
<p:panel  header="Oportunidades">
    <p:barChart id="graficoOportunidadesRepresentante" model="#{dashboardBean.barModel}" style="width:100%; height:420px"/>         
</p:panel>  

//Bean generation method:
public void criaGraficoOportunidadesPorRepresentante() {
    barModel = new BarChartModel();
    ChartData data = new ChartData();
    [...]
    data.setLabels(labels); //comes from the related sales rep's name
    barModel.setData(data); //backend fetches amounts from database

    // Options
    BarChartOptions options = new BarChartOptions();
    CartesianScales cScales = new CartesianScales();
    CartesianLinearAxes linearAxes = new CartesianLinearAxes();
    linearAxes.setStacked(true);
    cScales.addXAxesData(linearAxes);
    cScales.addYAxesData(linearAxes);
    options.setScales(cScales);

    Title title = new Title();
    title.setDisplay(true);
    title.setText(labelGraficoOportunidadesAtivas);
    options.setTitle(title);

    Tooltip tooltip = new Tooltip();
    tooltip.setMode("index");
    tooltip.setIntersect(false);
    options.setTooltip(tooltip);
    
    barModel.setExtender("chartOportunidadePorRepresentanteExtender");
    barModel.setOptions(options);
}
    
//Javascript extender: 
    function chartOportunidadePorRepresentanteExtender() {                             
               var options = $.extend(true, {}, this.cfg.config);
                options = {
                 options: {             
                    plugins: {
                      labels: {
                        render: 'value',
                        position: 'inside'
                      }
                    },
                    title: {
                        fontSize: 16
                    }
                  }
                  };           
               $.extend(true, this.cfg.config, options);
            };
//xhtml元素:
//Bean生成方法:
公共无效CRIAGRAFICOPortunidadesporRepresentante(){
barModel=新的BarChartModel();
ChartData数据=新的ChartData();
[...]
data.setLabels(labels);//来自相关销售代表的姓名
barModel.setData(data);//后端从数据库获取金额
//选择权
BarChartOptions=新的BarChartOptions();
CartesianScales cScales=新的CartesianScales();
CartesianLinearAxes linearAxes=新的CartesianLinearAxes();
linearAxes.固定(正确);
cScales.addXAxesData(linearAxes);
cScales.addYAxesData(linearAxes);
选项。设置刻度(cScales);
标题=新标题();
title.setDisplay(true);
标题.setText(labelGraficoOportunidadesAtivas);
选项。设置标题(标题);
工具提示工具提示=新工具提示();
工具提示。设置模式(“索引”);
工具提示.setIntersect(false);
选项。设置工具提示(工具提示);
setExtender(“chartOportunidadePorRepresentanteExtender”);
barModel.setOptions(选项);
}
//Javascript扩展程序:
函数ChartOportionAddeporRepresentanteExtender(){
var options=$.extend(true,{},this.cfg.config);
选项={
选项:{
插件:{
标签:{
render:'值',
位置:“内部”
}
},
标题:{
字体大小:16
}
}
};           
$.extend(true,this.cfg.config,options);
};
我希望条形图上的数字不要渲染,因为它们在元素的工具提示上更清晰,并且堆叠在一起
AFAIK,label指的是rep的名称,每个数据集也有一个“.setLabel(String)”方法,它在图表标题和内容之间呈现。我找到了一些引用“legend”属性的解决方案,但它取消了迄今为止所谓的label属性。

我已经管理好了它。在js扩展器中:

labels: {
         render: 'value',
         fontSize: 0
         }

我甚至不知道为什么我删除了“position:inside”值,我只是删除了。fontSize=0隐藏了数字。

也许我不明白,但在本例中,条形图上没有数字?它们只出现在工具提示上。没错,我的代码与示例几乎相同(除了扩展器,它的删除刚刚从整数更改为百分位数),您是否尝试删除扩展器以查看它的外观?您的扩展器可能正在删除其他设置,因为我看到您正在设置
标签
。是的,通过这样做而不是数字,我在条形图顶部得到了百分位值。我想PF Showcase不会有相同的行为,但它没有?你的某些方面一定有所不同。