Hello. I am using the chart component. I've added 25 datasets each pulling in a different set of SQL timeseries data. There are also 25 checkboxes, when checked, the corresponding chart becomes visible on the chart object. I am currently using a single Y-Axes for all the datasets, which in term shows the same "Axis Label". I am using the Y-Axis Label to indicate the Unit of Measure. Every Dataset unfortunately has a different unit of measure. Some are in PSI, some in GPM and so forth. Is there a way to dynamically assign a Y-Axis depending on which charts are checked? For example if Checkboxes 1,2 are check and they are in PSI, enable the Y-Axis Labeled PSI and if checkboxes 5,6,7 are checked and they are in GPM, enable the Y-Axes Labeled GPM. I know I can create multiple Y-Axes and assign each dataset to its own Y-Axes, but in my case the datasets are also dynamic meaning dataset1 could be GPM but next day Dataset1 could change to PSI. I also noticed in the charts scripting/extensions there is a configureChart. My gut feeling is this is where this sort of configuration can be done, where depending on a checkbox it assigns/enables the required Y-Axes. I cannot find any documentation or examples on this subject. Any assistance would be appreciated.
You can change the label directly with scripting:
#Replace this with the relative path to the chart component chartComponent = system.gui.getParentWindow(event).getComponentForPath('Root Container.Chart') dynamicLabel = '0 to 100 PSI' #Change string to whatever you want it to say chartComponent.chart.plot.rangeAxis.label = dynamicLabel
Since you have a fixed set of charts, just create all the different Y-axes you need, then assign them in the dataset properties tab. When the desired pens are selected, the corresponding Y-axis (or multiple) will show.
Hi Justin. Thanks for giving me your time. I tried your solution and it does work, but it doesn't quite solve my problem. It does change the Y-Axis, but it doesn't address the case when multiple charts with different y-axis are selected. In my mind, if I add all the possible Units of measure in the chart Customizer/Y-Axis tab, I would want to programmatically (trigger the change upon chart checkbox selected) change the Y-Axis for chart1 say from PSI to GPM. This will in turn enable/show that Axis. I could potentially have all the charts selected and multiple Y-Axis will be enabled on the chart.
Is there a link on ignitions site that exposes the charts methods for python?
Hi Phil. Thanks for taking the time to assist. Unfortunately this solution won't work as the charts units of measure is dynamic and one day chart1 might be in PSI and require the use of the PSI Y-Axis and the next day the same chart1 might change to GPM and will require the use of the GPM Y-Axis. I am after a method to dynamically change a charts Y-Axis in scripting.
Ah, I see. This is a bit trickier.
The classic chart hijacks the normal custom property functionality that most components offer to provide the attachment point for the various datasets you wish to plot. Instead of the common dynamic property configuration object as shown for getDynamicProps(), the PMIChart requires that each dynamic property be one of these: DataSetDescriptor
If you study that javadoc, you will see that all of the stuff you can do with the configuration tool in the designer is exposed there, including setting the Y-axis you wish to use for the given dataset.
In order to make the chart notice changes you make, you will probably need to get the entire Map<> of custom properties, construct a new map with the complete set, including your changes, then assign it back to the chart.
Also note that, if you plan on supplying data for your charts via scripting instead of binding, it is practical to construct your custom property map with configuration entirely dynamically. Then the pen control UI becomes optional.
Thank you Phil. I will go through the documentation and hopefully resolve this.