Charts - Category axis makes graph blank?

Hi Support Team,

I am a bit of a novice when it comes to using the charts library and can’t seem to get the category axis to work correctly.

When I add a category axis, the graph goes blank.

Have tried to add “byDate” in the graph xml, “parseDate” in the category axis, setting the datadateformat etc etc but it doesn’t seem to display correctly.

Please could you provide an example of how this should be done correctly?

(I would like the category labels to be date formatted to “MMM-yy”)

I have attached a sample project of the graph.

Thank you

Kind regards

Mattsamplechartproject.zip (98.4 KB)

Hello!

The AmCharts scales dates by period and to override format you should provide a full array of them. Take a look at this article about periods: Formatting dates on category axis.

In CUBA you can do the following:

<chart:categoryAxis>
    <chart:dateFormats>
        <chart:dateFormat period="MILLISECONDS" format="JJ:NN:SS"/>
        <chart:dateFormat period="SECONDS" format="JJ:NN:SS"/>
        <chart:dateFormat period="MINUTES" format="JJ:NN"/>
        <chart:dateFormat period="HOURS" format="JJ:NN"/>
        <chart:dateFormat period="DAYS" format="MMM-YY"/> // custom format
        <chart:dateFormat period="WEEKS" format="MMM-YY"/> // custom format
        <chart:dateFormat period="MONTHS" format="MMM"/>
        <chart:dateFormat period="YEARS" format="YYYY"/>
    </chart:dateFormats>
</chart:categoryAxis>

Hi Roman :slight_smile:

Sorry for the slow reply, was out of office until today.

That has shown the graph now which is good :slight_smile: but not quite what I was expecting to happen.

Here is the graph now:

image

But I was only expecting to see 2 bars and 2 dates. (Jan-21 and Feb-21)

How would I get it to ignore empty dates please?

Thank you very much for your help

Kind regards

Matt

Try to set equalSpacing="true" in the categoryAxis. It enables to place date items at equal intervals (see AmCharts doc: equalSpacing).

you’re a star Roman :slight_smile:

Thank you for your help

Kind regards

Matt