Rendering Time X Axis Chart

Hello!

I need help understanding how can I render the plotting of a Chart in Vision ( I am using ignition platform 8.1.43 and vision module 11.1.43).

I make a tag history query, between two dates, (start date binding and end date binding). This fill the chart dataset .

When the interval is only 1 day, it fill X Axis chart in hours. Then if I change it to several days, it fill x-axis in hour too, but in this case i want to change this to days, not hours.

How can I set the vision chart scale axis?

Thanks
Leandro

Is this the EasyChart or the Classic Chart? The EasyChart does its own history queries for all pens based on the resolution you configure (or bind) on the component.

The Classic Chart expects you to supply whatever history binding and/or custom computed datasets you wish, and simply plots that information.

Show more details of your case.

Hi @pturmel

Thank you for the answer. Sure, let me go deeper with the information.

I am using the classic chart, and I am filling its dataset throuhg an query tag history, with a fixed sample size.
I am selecting date intervals that can go from one day to thirty days. If I select one day, chart fills x-Axis in hours.

Then if I change the date interval to seven days, chart render again the x-Axis in hours.

After that, I increment the date interval of the query to thirty days. This time, Chart scale x-Axis in days.

Then, I roll back to seven days, and the chart scale this in days, not in hours as it did before.

I need to set the scale of the x-Axis chart previous it is rendered, and I don't understand
if "Vision - Chart Scripting Functions" can help in this stuff

Thanks

Yes, you will probably want to use the configureChart extension function to tweak the X-axis settings (JFreeChart) based on your actual date range.

Thank you for the answer.
Yes, i want to use the configureChart in order to set the x-Axis, but I don't understand which functions help me to set days instead of hour range.

I was using to set some properties this configureChart script (to set decimals colors and so)

def configureChart(self, chart):
from java.awt import Color
from org.jfree.chart.renderer.category import StandardBarPainter
from java.text import DecimalFormat

oPlot = chart.getPlot()
oRenderer = oPlot.getRenderer()

oPlot.setDomainGridlinePaint(Color(85, 85, 85))
oPlot.setRangeGridlinePaint(Color(85, 85, 85))

oRenderer.setShadowVisible(False)
oRenderer.setBarPainter(StandardBarPainter())

oPlot.getRangeAxis(0).setNumberFormatOverride(DecimalFormat("#,##0.0"))

It can be done like this:

from org.jfree.chart.axis import DateTickUnit

# Sets the tick units to one tick per day
chart.plot.domainAxis.tickUnit = DateTickUnit(DateTickUnit.DAY, 1)

# Sets the tick units to one tick per hour
chart.plot.domainAxis.tickUnit = DateTickUnit(DateTickUnit.HOUR, 1)
1 Like

Welcome to the forum, Leandro. Please see Wiki - how to post code on this forum. (You hit the " blockquote button instead of the </> preformatted text button.)

1 Like

Thank you very much. This solved the issue.
I used it every time I need to show data trends in charts.

1 Like