Dynamically modifying chart axes during runtime

I’ve got a project where we have multiple charts that all should be set to the same scale, but the bounds are determined (and will change) during runtime. I see that axis objects have properties that may be modified in a script to accomplish this. However, I can’t find how to get a reference to an axis. What function do I need to call?

Thanks

Which chart are you referring to? If is the Easy Chart, you simply have to modify the values in the “axes” dataset (its an expert-level property)

It is not an Easy Chart, it is a regular Chart.

In that case, I have a question: How dynamic are the ranges? Is there a small number of pre-set ranges, or are the ranges truly arbitrary?

The lower bound is always 0. It’s fine for the upper bound to be something like multiples of 100, rather than an exact maximum. Basically, I need something that will do the following:

  1. All charts at the same scale
  2. The chart with the maximum value is reasonably well scaled to the data

I will typically have some idea of a reasonable upper bound, although it would be better if I could assume I don’t, as this will process many different sources of data.

Why don’t you simply make two different Y axes - one at your basic scale, and the other one auto ranges, and then switch between the two using chart.setDatasetYAxis(datasetName, axisName)

Autorange is not an option; all charts would autorange to their own data, so they will be at different scales.

A very inelegant solution would go along the lines of setting up many different axes with a max of 100, 200, 300, …, although it seems there has to be a better way of doing it than that.

I see in the chart customizer that the property I want to change has a scripting name of “upperBound”. What I’d like to do is something like this:

myMaximum = maxValue( myData )
for myChart in setOfCharts:
    myAxis = myChart.getCurrentYAxis()
    myAxis.upperBound = myMaximum

The thing I can’t do is the line where I get a reference to the current Y axis. Any idea how to solve this?

Thanks for your help.

Python Y axis reference for Chart - I’m not sure. Carl or Travis?

Why are you using the Chart versus Easy Chart? The only “good” answer that comes to mind is if you’re not using a date/time based X axis.

This general approach will allow you to auto-manually scale axis on an Easy Chart. If you have a varying number of axis that are dynamic, it may not be possible. This simple example should illustrate the technique.

  1. Create an Integer dynamic property. Bind it to a query that determines the axis based on your selected date range. Something like:
SELECT 100+round(max(MyData),2) WHERE t_stamp in my range
  1. Save the Easy Chart’s (Expert) Axes settings in a table in your database. You may want to add an extra column to use with a custom WHERE clause.
  2. Bind the Easy Chart Axes property to a custom SQL query. The trick is that you will SELECT the plugged in value of your dynamic property AS UPPER_BOUND. It will look something like this:
SELECT *, {Root Container.max_axis} AS 'UPPER_BOUND' FROM my_axis

Start by baby stepping, editing the dataSet manually and gradually pick things apart. Once you get the idea, you can tailor everything to work together nicely and support multiple axis. You may be better off using SQLTags, storing your range results in the database, or figuring out the ranging within #3 (bound to be complex). I don’t have a good feel for the complexity of what you’re trying to do. Ultimately, there’s always scripting.