Skip to main content
Jan 2, 2022 3:11 PM UTC
Question

Bar Chart XAxisFormat Issue

In Bar Chart there is no XAxisFormat present in the widget property. As present situation the XAxis is TimeStamp. Where default format is YYYY:MM:DD HH:MM:SSS, as per the use case by the customer it should in the YY:MM:DD.

So this should be done in the Service or, there is work around for this ?

Thingworx version: 9.3

Thanks,
Shashi

7 replies

Jan 5, 2022 3:49 AM UTC

Hi Shashi,

 

As a workaround you can use line chart widget instead.

After binding the data, setting the XAxisField, look for the XAxisDateFormatToken property and set it to sth like YY/MM/DD

https://www.ptc.com/en/support/article/CS341400

Jan 5, 2022 4:20 AM UTC

Hi @TonyZhang ,

Thanks for the response, but as per use case bar chart is needed, can't go for another alternative chart.

Thanks,
Shashi

Jan 5, 2022 9:09 AM UTC

Hi Shashi,

 

In that case you will probably need to create a custom service to transform your data,

in the custom service create a new infotable as the data source to feed the bar chart based on a new datashape (change DateTime field to type String for the XAxis of the Bar Chart)

 

You may use below snippets to loop through the existing infotable, transform the DateTime value to String with specified format and write each row to the new infotable.

//loop through infortable

.rows.toArray().forEach(row => {
   
});

//convert DateTime to String

dateFormat(row.timestamp, "yy-MM-dd");

 

Also you can post your enhancement ideas for Bar Chart Widget on below site.

https://community.ptc.com/t5/ThingWorx-Ideas/idb-p/thingworxideas

Jan 8, 2022 8:01 AM UTC

Hi,

@paic @slangley @c_lowy @VladimirN @CarlesColl , can't Localization token can be set for the X-AxisFormat from the custom css ?

Thanks
Shashi.