2011-06-02 57 views
0

我有兩個關於AspxPivotGrid的問題。AspxPivotGrid和WebCharControl問題

當我使用自定義窗口並在「行區」和「數據區」中添加列並更新報表時。網格正確生成,但不會生成圖形。但是,如果在「列區域」中添加一個字段,則會生成圖形。

即使「數據區域」標題正好是我們需要的數據,它似乎只在指定了至少一列時纔會生成圖表。我用你在網站上的圖形演示來模擬這一點。這是預期的行爲?

其次,當我將'DateTime'添加到'Row Area'和一個字符串'Column Area'時,它很好。然後我交換了這些柱子,再次關鍵點很好。切換回來,你會得到以下錯誤:

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) 

任何建議/解決方案?

+0

感謝您對格式化Soner的幫助! – Madabitjer 2011-06-02 05:46:41

回答

1

如果在「行區」和「數據區」中有字段,但在「列區」中沒有字段,則網格將顯示列總計。您可以通過設置ShowColumnGrandTotals屬性在圖表中顯示這些,例如:

ASPxPivotGrid1.OptionsChartDataSource.ShowColumnGrandTotals = True 

不顯示總計的默認值是可以理解的,因爲大多數圖表顯示兩種:

  • 聚合值由分組行或 列字段,但沒有總計或
  • 只有來自行或 列的總計值。
0

我有同樣的錯誤:

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

當用戶改變在樞軸網格由列或反之亦然的行它發生。要解決這個問題,我想這段代碼,和它的工作對我來說:

 //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; 
    } 

它適用於最圖表類型,但FullStakedLine發生在這裏不涉及其他錯誤。