Page 1 of 1

Setting values in a chart pie by code

Posted: Tue Jan 12, 2016 6:08 pm
by JeffB
Hi,

I want to set the values to a chart pie by code with a datasource.

I see with the debugger that the value is taken, but at the end I have an error message with:
A first chance exception of type 'System.InvalidCastException' occurred in Stimulsoft.Report.dll

And the stack trace:
à Stimulsoft.Report.Chart.StiChartHelper.GetValuesFromValueDataColumn(StiChart masterChart, StiSeries series)
à Stimulsoft.Report.Chart.StiChartHelper.GetValues(StiChart masterChart, StiSeries series)
à Stimulsoft.Report.Chart.StiChartHelper.CreateChart(StiChart masterChart, StiChart chartComp)
à Stimulsoft.Report.Engine.StiChartV2Builder.RenderChart(StiChart masterChart)
à Stimulsoft.Report.Engine.StiChartV2Builder.InternalRender(StiComponent masterComp)
à Stimulsoft.Report.Components.StiComponent.InternalRender()
à Stimulsoft.Report.Engine.StiComponentV2Builder.Render(StiComponent masterComp)
à Stimulsoft.Report.Components.StiComponent.Render()
à Stimulsoft.Report.Engine.StiContainerV2Builder.InternalRender(StiComponent masterComp)
à Stimulsoft.Report.Engine.StiBandV2Builder.InternalRender(StiComponent masterComp)
à Stimulsoft.Report.Components.StiComponent.InternalRender()
à Stimulsoft.Report.Engine.StiEngine.InternalRenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents, Boolean& isChildsEnabled)
à Stimulsoft.Report.Engine.StiEngine.RenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents)
à Stimulsoft.Report.Engine.StiDataBandV2Builder.RenderBand(StiDataBand masterDataBand, StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents)
à Stimulsoft.Report.Engine.StiDataBandV2Builder.RenderMaster(StiDataBand masterDataBand)
à Stimulsoft.Report.Components.StiDataBand.RenderMaster()
à Stimulsoft.Report.Engine.StiPageHelper.RenderPage(StiPage page)
à Stimulsoft.Report.Engine.StiRenderProviderV2.RenderReport(StiReport report, StiReport masterReport, StiRenderState state)
à Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
à Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)

I have tried to put IEnumerable<double>, double[] and double?[] but this is always the same
(double?[] does a special thing because the ? is converted into a special char into the report code and the report become useless).

Have you a sample to show me or the good type to use? Is it a StiSeries/StiPieSeries/...?

Thanks.

Re: Setting values in a chart pie by code

Posted: Wed Jan 13, 2016 9:21 am
by HighAley
Hello.

Did you add a DataSource? How do you set values in the chart?
Please, send us a report template that reproduces the issue and your code.

Thank you.

Re: Setting values in a chart pie by code

Posted: Wed Jan 13, 2016 10:53 am
by JeffB
Sorry, not possible to send you a report sample, too complicated.

Here a simplified part of the code:

Code: Select all

this.UserData = new StiUserData();
this.UserData.GetData += new StiUserGetDataEventHandler(this.GetDataDelegate);

private void GetDataDelegate(object sender, StiUserGetDataEventArgs e)
{
	UpdatePosition(e.Position);
	if (this.currentRow == null)
	{
		e.Data = string.Empty;
		return;
	}
	e.Data = typeof(T).InvokeMember(e.ColumnName, BindingFlags.GetProperty, null, this.currentRow, null);
}
And the called property:

Code: Select all

public double[] PieQuotationsCountValues
{
	get
	{
		if (this.quotes == null) return new double[]{ 1, 2, 3 };

		return new double[] { this.QuotationsCount, this.OrdersCount };
	}
}
And I use PieQuotationsCountValues as a datasource.

Re: Setting values in a chart pie by code

Posted: Wed Jan 13, 2016 2:58 pm
by HighAley
Hello.

Unfortunately, this is not enough to help you.
Could you prepare and send us a simple VS-project that reproduces the issue?

Thank you.