Dynamic number of chart series on column chart

UI Components for JSF
giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

29 Dec 2009, 16:45

Hi,

I found this post on the forum http://primefaces.prime.com.tr/forum/vi ... 61&start=0, but I'm not sure I understand the steps. Can you please add some details how that can be achieved? Is there a more built-in solution not involving code changes?

Thanks.

giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

30 Dec 2009, 14:01

Hello again,

Can someone assist please with that issue? I've tried different solutions I found in the web, but none of them really works... :-(

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

30 Dec 2009, 15:25

Can you post your code? Thanks.

giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

30 Dec 2009, 15:54

Sure.

Code: Select all

<p:columnChart value="#{statsBean.categories}" var="category" xfield="#{category.id}" binding="#{statsBean.chart}" styleClass="column" style="chartStyle"  id="cats">
		<ui:repeat value="#{statsBean.categories}" var="category1">
  			<p:chartSeries label="#{category1.id}" value="#{category1.amount}" />
		</ui:repeat>
	</p:columnChart>
The data in the chart is not rendered. I've understood that there is some problem with ui:repeat, than can be solved using binding, but I haven't figured out how to do that. Can you please list the required steps, or suggest a solution that not requires changes in the backing bean?

Thanks.

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

30 Dec 2009, 16:25

Can you try c:forEach instead of ui:repeat?

giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

30 Dec 2009, 16:34

For some reason, this code

Code: Select all

<p:columnChart value="#{statsBean.categories}" var="category" xfield="#{category.id}" binding="#{statsBean.chart}" styleClass="column" style="chartStyle"  id="cats">
      <c:forEach items="#{statsBean.categories}" var="category1">
           <p:chartSeries label="#{category1.id}" value="#{category1.amount}" />
      </c:forEach>
   </p:columnChart>
caused infinite loop :-(

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

30 Dec 2009, 16:35

Hmm, any clue who caused the loop? Stack trace can help.

giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

30 Dec 2009, 16:49

I put a breakpoint on the get method and captured that - is it helps?

LuceneStatslBean.getCategories() line: 75
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
BeanELResolver.getValue(ELContext, Object, Object) line: 62
FacesCompositeELResolver(CompositeELResolver).getValue(ELContext, Object, Object) line: 53
FacesCompositeELResolver.getValue(ELContext, Object, Object) line: 72
AstValue.getValue(EvaluationContext) line: 118
ValueExpressionImpl.getValue(ELContext) line: 186
TagValueExpression.getValue(ELContext) line: 71
IndexedValueExpression.getValue(ELContext) line: 49
AstIdentifier.getValue(EvaluationContext) line: 57
AstValue.getValue(EvaluationContext) line: 107
ValueExpressionImpl.getValue(ELContext) line: 186
TagValueExpression.getValue(ELContext) line: 71
ChartSeries.getLabel() line: 52
ColumnChartRenderer.encodeSeriesDef(FacesContext, UIChart, List<ChartSeries>) line: 118
ColumnChartRenderer.encodeChartScript(FacesContext, UIChart) line: 53
ColumnChartRenderer(BaseChartRenderer).encodeEnd(FacesContext, UIComponent) line: 53
ColumnChart(UIComponentBase).encodeEnd(FacesContext) line: 861
ColumnChart(UIComponent).encodeAll(FacesContext) line: 937
UIViewRoot(UIComponent).encodeAll(FacesContext) line: 933
FaceletViewHandler.renderView(FacesContext, UIViewRoot) line: 592
RenderResponsePhase.execute(FacesContext) line: 110
RenderResponsePhase(Phase).doPhase(FacesContext, Lifecycle, ListIterator<PhaseListener>) line: 100
LifecycleImpl.render(FacesContext) line: 139
FacesServlet.service(ServletRequest, ServletResponse) line: 266
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 290
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
PDFRenderingFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 74
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
CharacterEncodingFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 32
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
FileUploadFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 79
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
StandardWrapperValve.invoke(Request, Response) line: 233
StandardContextValve.invoke(Request, Response) line: 191
StandardHostValve.invoke(Request, Response) line: 128
ErrorReportValve.invoke(Request, Response) line: 102
StandardEngineValve.invoke(Request, Response) line: 109
CoyoteAdapter.service(Request, Response) line: 286
Http11Processor.process(Socket) line: 845
Http11Protocol$Http11ConnectionHandler.process(Socket) line: 583
JIoEndpoint$Worker.run() line: 447
Thread.run() line: 619

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

04 Jan 2010, 15:15

Not really sorry. I think what you can do is do a binding to a backing bean and add child chartSeries components programmatically. That should do it.

giladno
Posts: 20
Joined: 29 Dec 2009, 16:39

06 Jan 2010, 14:51

Is there a simple guide describing how to do that? I'm looking at the javadoc and cant find the relation between ColumnChart and ChartSeries...

Excuse for my ignorance, but so far most of expirience with PrimeFaces is through the tag lib...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests