jkarippery
(Jkarippery)
August 16, 2018, 11:09am
#1
i want to create a pie chart from new table.
In my order table i have user name and product name. different users have same items . I want to create new table Item name and user count.
i want to count item . it also increment after new order will happen.
example
Name Users
apple 25´
orange 10
pineapple 5
can you help me please
shiryaeva
(Olga Shiryaeva)
August 20, 2018, 12:51pm
#3
Hi,
You can create a valueCollectionDatasource for the pieChart
data binding, for example:
<valueCollectionDatasource id="chartDs">
<query>
<![CDATA[select e.product, count(e.user.id) from demo$Order e group by e.product]]>
</query>
<properties>
<property name="product" class="com.company.demo.entity.Product"/>
<property name="count" datatype="int"/>
</properties>
</valueCollectionDatasource>
<chart:pieChart id="pieChart"
height="150px"
datasource="chartDs"
titleField="product"
valueField="count"
width="100%">
<chart:legend position="RIGHT"/>
</chart:pieChart>
See the similar example in the workshop sample .
jkarippery
(Jkarippery)
August 21, 2018, 1:13pm
#4
thank you for your help. now i have another problem. when I run this program chart is not displaying.
shiryaeva
(Olga Shiryaeva)
August 21, 2018, 1:26pm
#5
There’s an error in your valueField
: the “user” property does not exist in the chart’s datasource.
Set valueField="count"
, and is should work.
jkarippery
(Jkarippery)
August 21, 2018, 1:45pm
#6
thank you so much… now it is working… oho oh
1 Like