Charts Primefaces

Asked

Viewed 87 times

0

I am having the following problem I have the following class that receives the values of the graph of information collected in real time from the bank

@ManagedBean
public class ChartView implements Serializable {

private BarChartModel barModel;

@PostConstruct
public void init() {
    createBarModels();
}

public BarChartModel getBarModel() {
    return barModel;
}

private BarChartModel initBarModel() {
    BarChartModel model = new BarChartModel();
    SQL_ServerControle qtdusers = new SQL_ServerControle();

    try {
        ChartSeries quantidadeDeUsuarios = new ChartSeries();
        quantidadeDeUsuarios.setLabel("Quantidade de Usuarios");
        quantidadeDeUsuarios.set("Qtd Usuarios", qtdusers.qtdUsuariosI());
        ChartSeries transacoes_ativas = new ChartSeries();
        transacoes_ativas.setLabel("Transações Ativas");
        transacoes_ativas.set("Trans Ativas", qtdusers.trasacoesAtivasI());
        ChartSeries transacoes_alocadas = new ChartSeries();
        transacoes_alocadas.setLabel("Transações Alocadas");
        transacoes_alocadas.set("Trans Alocadas", qtdusers.trasacoesAlocadasI());
        ChartSeries quantidadeUsuariosP = new ChartSeries();
        quantidadeUsuariosP.setLabel("Quantidade Usuários Progress");
        quantidadeUsuariosP.set("Qtd Usuarios Progress", qtdusers.qtdUsuariospI());
        ChartSeries quantidadeUsuariosApp = new ChartSeries();
        quantidadeUsuariosApp.setLabel("Usuarios APP Server");
        quantidadeUsuariosApp.set("Qtd Usuarios App Server", qtdusers.usuariosAppQtdI());
        ChartSeries quantidadeSqlClient = new ChartSeries();
        quantidadeSqlClient.setLabel("SQL Client");
        quantidadeSqlClient.set("Qtd SQL Client", qtdusers.QtlSQLClientI());

        model.addSeries(quantidadeDeUsuarios);
        model.addSeries(transacoes_ativas);
        model.addSeries(transacoes_alocadas);
        model.addSeries(quantidadeUsuariosP);
        model.addSeries(quantidadeUsuariosApp);
        model.addSeries(quantidadeSqlClient);

    } catch (SQLException ex) {
        Logger.getLogger(ChartView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(ChartView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(ChartView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(ChartView.class.getName()).log(Level.SEVERE, null, ex);
    }

    return model;
}

private void createBarModels() {
    createBarModel();
}

public void createBarModel() {
    barModel = initBarModel();
    barModel.setLegendPosition("ne");

    Axis yAxis = barModel.getAxis(AxisType.Y);

    yAxis.setMin(0);
    yAxis.setMax(100);

}

I have the following Chart on my jsf screen:

what happens is that when loading the chart the names under each graph do not appear, appears only the first "Qty Users" and centered in the middle I need to appear the name I specified for each one, and that each one has a different color, if anyone can help me I’m grateful.

1 answer

0

chartSeries.set receives 2 parameters:

ChartSeries chartSeries = new ChartSeries;

chartSeries.set("Qtd usuarios", valor);
chartSeries.set("Trans Ativas", valor);
chartSeries.set("Trans Alocadas", valor);
chartSeries.set("Qtd Usuarios Progress", valor);

then the first parameter will appear as the value subtitle.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.