Ruaan
Ruaan

Reputation: 180

AspxPivotGrid and WebCharControl Issues

I've got two questions/issues regarding the AspxPivotGrid.

When I use the customization window and add columns in the 'Row Area' and 'Data Area' and update the report. The grid generates properly but the graph doesn't generate. However when you add a field in the 'Column Area', the graph then generates.

It appears that the graph only generates when there are at least a column specified, even though the 'Data Area' headers is exactly the data we need. I have simulated this with the graph demo you have on your site. Is this expected behavior?

Secondly, when I add a DateTime to the 'Row Area' and a String 'Column Area' it's fine. I then swap the columns around, again the pivot is fine. Switch it back again you get the following error:

System.ArgumentException: The type of the "Arguments" argument data member isn't compatible with the date-time scale.

at DevExpress.XtraCharts.SeriesBase.CheckArgumentDataMember(Object dataSource, String dataMember, ScaleType argumentScaleType)

Any suggestions / solutions?

Upvotes: 0

Views: 2261

Answers (2)

Fernando Luiz
Fernando Luiz

Reputation: 1

I was having the same errors:

The type of the "Arguments" argument data member isn't compatible with the numeric scale

The type of the "Arguments" argument data member isn't compatible with the datetime scale

It was happening when user changed the rows by columns or vice-versa in the pivot grid. To workaround this issue, i tried this code, and it works for me:

        //Always make the chart visible then perform DataBind() //Sempre deixar o gráfico visivel e depois executar o método DataBind()
        try
        {
            dxGrafico.Visible = true;
            dxGrafico.RefreshData();
            dxGrafico.DataBind();
        }
        catch (Exception ex)
        {
            //Try to fix the error: The type of the "Arguments" argument data member isn't compatible with the <data type> scale //Tentar corrigir o Erro
            bool bTeste = false;
            bTeste = Ajuste_Grafico_ScaleType(ex);

            //If not fix the argument scale type, then show error message label //Se não conseguir corrigir , acrescenta um label com texto da mensagem de erro
            if (!bTeste)
            {
                //Make the chart not visible and Add a label on the Page Control that the owners the chart //Deixar o gráfico invisível e exibir o label com mensagem no objeto PageControl que contém o gráfico
                dxGrafico.Visible = false;
                try
                {
                    //Error Message (Mensagem de Erro)    
                    ASPxLabel lbl = new ASPxLabel();
                    lbl.ID = "lblMensagemErroGrafico";
                    lbl.Text += "\n\n" + "ATENÇÃO: Não Foi possível Processar o Gráfico" + "";
                    lbl.Text += "\n\n" + "Tente utilizar outro tipo de Gráfico" + "";
                    lbl.Text += "\n\n" + ex.Message + ""; //lbl.Text += "\n\n" + ex.ToString() + "";
                    this.pgControl.TabPages[1].Controls.Add(lbl);
                }
                catch (Exception ex1) { }
            }

        }

    //method Try to fix the error 
    private bool Ajuste_Grafico_ScaleType(Exception exOrigem)
    {
        //Try to fix error argument ArgumentScaleType (Tenta ajustar erro)
        bool saida = false;

        try
        {

            //Auto
            try
            {
                dxGrafico.SeriesTemplate.ArgumentScaleType = ScaleType.Auto;
                dxGrafico.DataBind();
                dxGrafico.SeriesTemplate.ValueScaleType = ScaleType.Auto;
                dxGrafico.DataBind();
                saida = true;
                return saida;
            }
            catch (Exception e) { }

            //Numeric
            try
            {
                int n = exOrigem.Message.ToString().IndexOf("Numeric", 0, StringComparison.OrdinalIgnoreCase);
                if (n >= 0)
                {
                    dxGrafico.SeriesTemplate.ArgumentScaleType = ScaleType.DateTime;
                    dxGrafico.DataBind();
                    dxGrafico.SeriesTemplate.ValueScaleType = ScaleType.DateTime;
                    dxGrafico.DataBind();
                    saida = true;
                    return saida;
                }
            }
            catch (Exception e) { }


            //Date Time
            try
            {
                int n = exOrigem.Message.ToString().IndexOf("Date", 0, StringComparison.OrdinalIgnoreCase);
                if (n >= 0)
                {
                    dxGrafico.SeriesTemplate.ArgumentScaleType = ScaleType.Numerical;
                    dxGrafico.DataBind();
                    dxGrafico.SeriesTemplate.ValueScaleType = ScaleType.Numerical;
                    dxGrafico.DataBind();
                    saida = true;
                    return saida;
                }
            }
            catch (Exception e) { }

        }
        finally
        {

        }

        return false;
    }

It works for the most chart types, but to FullStakedLine happened another error not related here.

Upvotes: 0

mika
mika

Reputation: 6962

If you have fields in the 'Row Area' and 'Data Area', but not in the 'Column Area', the grid shows the column grand totals. You can show these in the chart by setting the ShowColumnGrandTotals property, e.g.:

ASPxPivotGrid1.OptionsChartDataSource.ShowColumnGrandTotals = True

The default value of not showing grand totals is understandable, since most charts show either:

  • aggregate values grouped by a row or column field, but no grand totals, or
  • only grand total values from rows or columns.

Upvotes: 1

Related Questions