Chart's query result, chart legend property

Hi,

So I tried to make a chart, with a blank screen based this tutorial. But when I run the project, the chart doesn’t appear. I did everything like in the tutorial, only I missed the
<chart:legend position=“LEFT”/>
from xml, because if I put that in, I got an Exception:


GuiDevelopmentException: Unknown component: legend

Frame ID: SzaarChart
XML descriptor: com/company/gdpr/web/szemely_adata_a_rendszerben/SzaarChart.xml

Unfortunately the tutorial doesn’t tell me why it is needed, and when I search for it in the documentation I got a
HTTP Status 500 Exception
So I am very puzzled, where to go for solutions.

I guess maybe my Datasource’s query wrong.
This is my query:


select o.szemelytabla_rekord, count(o.id) from
gdpr$Szemely_adata_a_rendszerben o group by o.szemelytabla_rekord
szemelytabla_rekord 

is an associaton to a person table. For now I only want to count how much person I have in Szemely_adata_a_rendszerben (as Person’s data in system).

Should I run this query somewhere myProject’s database? What should be the result to show the chart?

Thanks so much,
Carol

Hello, Karolina

Could you please create a sample project that demonstrates the problem? Or at least share your screen descriptor. For now, it’s hard to say where the problem.

Regards,

Gleb

Okay I made a copy, which one likes mine, but unfortunately i got a null pointer exception at chart screen…
My original projects’s chart screen xml:


    <dsContext>
        <valueCollectionDatasource id="SzaarDs">
            <query>
                <![CDATA[select o.szems, count(o.id) from
gdpr$Szaar o group by o.szems]]>
            </query>
            <properties>
                <property class="com.company.gdpr.entity.Szems"
                          name="sztabla_rekord"></property>
                <property datatype="long"
                          name="count"></property>
            </properties>
        </valueCollectionDatasource>
    </dsContext>
    <dialogMode height="600"
                width="800"></dialogMode>
    <layout>
        <chart:pieChart id="SzemARChart"
                        datasource="SzaarDs"
                        width="100%"></chart:pieChart>
    </layout>

From your code, I see that you didn’t specify titleField and valueField for pieChart. ‘titleField’ is used to specify which attribute will be used for slice titles, valueField is used to specify which attribute will be used for slice values. You can read more about charts in the documentation and our samples.

Oh okay, you are right, now it works, thanks, but I do not understand, if that is a step by step tutorial, why they do not call attention for that. And what is that legend property good for?

Thank you so much!

CUBA chart display subsystem is based on AmCharts library and it’s more convenient to get information about chart’s fields designation from original AmCharts documentation. We also have charts documentation, but our documentation mainly focused on providing information about how to use charts inside CUBA application and how to port JSON configuration to CUBA way using XML and Java code.

In the tutorial you’ve mentioned, I see that chart configuration has titleField and valueField attributes. But, probably, it’s not obvious that you need to use them too. We will think about it. Thanks for your feedback.

Regards,

Gleb.