Loading chart data from arrays

Stimulsoft Reports.NET discussion
Post Reply
groo
Posts: 9
Joined: Tue Dec 11, 2012 1:39 pm

Loading chart data from arrays

Post by groo »

Hello everyone!

I am trying to load data into one of my charts from two arrays (double?[] and object[]), but it's not working.

I tried something as simple as this:

Code: Select all

chart.Series.Add(new StiLineSeries()
{
    Values = new double?[] { 50.0, 50.1, 50.2 },
    Arguments =  new object[] { "1", "2", "3" }
});
The chart is shown, and the line series seems to be added (there is a "Series1" label in the legend), but there is no data at all.

I am doing this right before showing the report, i.e. the full test code looks like this:

Code: Select all

private void ShowReportButton_Click(object sender, EventArgs e)
{
    var report = LoadReportFromEmbeddedResource("Report.mrt");
    var chart = (StiChart)report.GetComponentByName("MyChart");
    chart.Series.Add(new StiLineSeries()
    {
        Values = new double?[] { 50.0, 50.1, 50.2 },
        Arguments =  new object[] { "1", "2", "3" }
    });
    report.Show(true);
}
What am I doing wrong? Thanks a lot!

(if needed: I am using Stimulsoft Reports.Net v2012.3.1500, .NET4, Windows 7 x86)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading chart data from arrays

Post by HighAley »

Hello.

Sorry, we need a little more time to prepare an answer for you.

Thank you.
groo
Posts: 9
Joined: Tue Dec 11, 2012 1:39 pm

Re: Loading chart data from arrays

Post by groo »

Aleksey Andreyanov wrote:Sorry, we need a little more time to prepare an answer for you.
No problem, I am not in a hurry and this is not a stopping issue right now. Thanks!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading chart data from arrays

Post by HighAley »

Hello.

It's impossible to set Values and Arguments such way.
Look at the attached sample project how to create chart at runtime.

Thank you.
Attachments
CreateChartInRunTime.zip
(18.24 KiB) Downloaded 196 times
groo
Posts: 9
Joined: Tue Dec 11, 2012 1:39 pm

Re: Loading chart data from arrays

Post by groo »

Hi, thanks for the answer, it took me some time to get back to this, and now that I've tried it, I have one more tiny problem:

The series name in the legend is shown as "Series 1" (in the example you attached).

It looks like this line should be setting it:

Code: Select all

Item.TitleValue = "Chart in Run Time"; // Item is StiClusteredColumnSeries
I have also tried to handle the GetTitle event:

Code: Select all

Item.GetTitle += (s, e) => e.Value = "Chart in Run Time";
but the chart legend always displays "Series 1".

What could be the problem?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading chart data from arrays

Post by HighAley »

Hello.

Please, use next code to set title:

Code: Select all

Item.CoreTitle = "Chart in Run Time";
Thank you.
Post Reply