Skip to main content
18-Opal
January 2, 2022
Question

Bar Chart XAxisFormat Issue

  • January 2, 2022
  • 2 replies
  • 2944 views

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

2 replies

16-Pearl
January 5, 2022

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

18-Opal
January 5, 2022

Hi @TonyZhang ,

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

Thanks,
Shashi

16-Pearl
January 5, 2022

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

18-Opal
January 8, 2022

Hi,

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

Thanks
Shashi.