LineChart rendering problems with different series lenghts

UI Components for JSF
Post Reply
csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

04 Aug 2009, 12:37

Hi,

I'm trying to use LineChart. Problem is when trying to add 2 series with different length to the chart.

For example series1 has 3 elements and series2 has 10 elements. The javascript code that is created contains pairs like

Code: Select all

{xAxisValue:"value1",series1:valueS1_1,series2:valueS2_1},
{xAxisValue:"value2",series1:valueS1_2,series2:valueS2_2},
{xAxisValue:"value3",:series1,series:valueS2_3}
Note that on the 3rd line series1 has no value. Firebug tells me that there is a syntax problem. So the approach that I'm using isn't the correct one( I set the fields for the empty values as empty strings in my code).

Could anyone please give me a hint how to obtain a rendered chart when you have 2 series of different lengths?

Thanks in advance for your help.

Regards,
Csaba.

csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

04 Aug 2009, 12:40

I forgot to put ":" on line 3 after "{xAxisValue:"value3",:series1"

so the code looks like:

Code: Select all

{xAxisValue:"value1",series1:valueS1_1,series2:valueS2_1},
{xAxisValue:"value2",series1:valueS1_2,series2:valueS2_2},
{xAxisValue:"value3",:series1:,series:valueS2_3}
:D sorry

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Aug 2009, 19:33

Hi, what series values should be numbers so maybe you can try setting 0 instead of null? Would that work?

csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

05 Aug 2009, 08:06

Hey. Thanks for the fast answer.

If I set a series values to 0 after I have added some meaningful values the graph will represent these values. I need a representation where one of the series has let's say 3 values represented and the other one has 10. If you fill your first series remaining values from index 4 - 10 with 0 you will get a graph where the first series has its values set to 0 from a given index -> the graph does not represent correct information.

I think this kind of usage for multiple series would be great to have in primefaces charting.

Cheers,
Csaba.

csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

05 Aug 2009, 08:16

I'm adding an image of what the chart should look like. Hope it helps understanding my problem.

Image

Thanks,
Csaba.
Last edited by csaba.birtalan on 10 Aug 2009, 11:04, edited 2 times in total.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

05 Aug 2009, 18:24

The image doesn't open but now I see what you mean anyway. Chart seems to produce invalid javascript with your case, I'll look into it and update this post.

csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

31 Aug 2009, 15:37

Hi Cagatay,

Have you found anything related to this issue?

Regards,
Csaba.

csaba.birtalan
Posts: 6
Joined: 04 Aug 2009, 12:27

31 Aug 2009, 16:43

I did some investigation on the issue. And obtaining the results for this is quite simple.

When constructing the datasource object just add "null" for those values in the value pairs that you don't want to be displayed.
Eg:

Code: Select all

chartBean.add(new SomeBean(xAxisValue1,series1_value1,series2_value1));
chartBean.add(new SomeBean(xAxisValue2, series1_value2, series2_value2));
chartBean.add(new SomeBean(xAxisValue3, "null", series2_value3));
chartBean.add(new SomeBean(xAxisValue4, "null", series2_value4));
for the code listed above you will get 4 values on the x axis, 2 values displayed for series1 and 4 values for series2

Hope this helped someone.

Best regards,
Csaba.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

31 Aug 2009, 18:14

Thanks Csaba for sharing your solution, if this can be achieved by your method I don't see a need to change the current implemenation for this case. I'll document this anway. Thanks again.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests