我有同样的错误:
“参数”参数数据成员的类型与数字刻度不兼容
“参数”参数数据成员的类型与日期时间刻度不兼容
当用户在透视网格中按列更改行或反之亦然时,就会发生这种情况。为了解决这个问题,我尝试了这段代码,它对我有用:
//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
发生了另一个与此处无关的错误。