Ignition 8.1.25
I have an XY chart and I selected lines and shapes dataset type. The size of the shapes is a bit large for my liking since I can have hundreds of points. How can I use the configureChart function to adjust the size of these shapes?
Ignition 8.1.25
I have an XY chart and I selected lines and shapes dataset type. The size of the shapes is a bit large for my liking since I can have hundreds of points. How can I use the configureChart function to adjust the size of these shapes?
Got nerd-sniped.
Should work across multiple datasets and subplots.
def configureChart(self, chart):
size = 6
topPlot = chart.getXYPlot()
# Create plot list depending if subplots exist
if hasattr(topPlot, 'getSubplots'):
plotList = topPlot.getSubplots()
else:
plotList = [topPlot]
for plot in plotList:
datasetCount = plot.getDatasetCount()
for dsIndex in xrange(datasetCount):
dataset = plot.getDataset(dsIndex)
renderer = plot.getRendererForDataset(dataset)
for seriesIndex in xrange(dataset.seriesCount):
shape = renderer.getSeriesShape(seriesIndex)
shape.height=size
shape.width=size
shape.x = -size/2.0
shape.y = -size/2.0
renderer.setSeriesShape(seriesIndex, shape)
Default size of 6
Size of 4
Jordan,
This is better than I hoped. Thanks a ton!
Hi @JordanCClark and All,
Can we disable the shape for those lines in the single dataset? I have one dataset that contains four lines of chart. I'll give an Image for reference. I have Min, Max, Target, and Actual. These are the four Values I have in the dataset. I had to change the line into Line/Shapes in the chart properties. Then, all of the line styles are changed. But I should need to change the Line style for Actual only. Could you please help me to resolve this issue?
In Chart Customizer:
Thanks,
Muniyandi D
I'd make a filter to use the specific dataset column names.
def configureChart(self, chart):
size = defaultSize = 6
seriesFilter = ['HC CH5 590mm']
topPlot = chart.getXYPlot()
# Create plot list depending if subplots exist
if hasattr(topPlot, 'getSubplots'):
plotList = topPlot.getSubplots()
else:
plotList = [topPlot]
for plot in plotList:
datasetCount = plot.getDatasetCount()
for dsIndex in xrange(datasetCount):
dataset = plot.getDataset(dsIndex)
columnNames = list(dataset.getDataSetForSeries(0).getColumnNames())[1:]
renderer = plot.getRendererForDataset(dataset)
for seriesIndex, seriesName in enumerate(columnNames):
if seriesName in seriesFilter:
size = 0
else:
size = defaultSize
shape = renderer.getSeriesShape(seriesIndex)
shape.height=size
shape.width=size
shape.x = -size/2.0
shape.y = -size/2.0
renderer.setSeriesShape(seriesIndex, shape)
Thanks, @JordanCClark for your support. But I got an error whenever this script was run.
Sample Image:
And the mentioned column's data line's shape size is also not reduced.
FYR:
Pink - 'HC CH5 590mm'
Orange - Top - 'Max', Bottom - 'Min'
Green - 'Target'
Thanks,
Muniyandi D
Can you post a export of the window? If the dataset property is bound to something, remove the binding first, to preserve the data. I should be able to take a closer look this afternoon (currently, its 4am here )
EDIT: Also, what version of Ignition? Just to be sure I'm on the same page.
Thank You @JordanCClark for your reply messages at 4 am. I'll add an example window and one client tag for that chart. Should need to assign the substrate_id column in the tag as "Manz ID" fro that charts.
Chart_dataset_tags.json (96.9 KB)
Chart_Example_Window.zip (45.4 KB)
You can use this to Check and validate which error has throwing while running the script.
Our ignition version is 8.1.33 (b2023101913)
Thanks,
Muniyandi D
Sorry for the late reply. Work requirements are building up...
Anyway, here's a quick and dirty one that will hide series shapes only. No resizing, as, in my limited time, resizing a polygon is a pain.
def configureChart(self, chart):
seriesFilter = ['HC CH5 590nm', 'Target']
topPlot = chart.getXYPlot()
# Create plot list depending if subplots exist
if hasattr(topPlot, 'getSubplots'):
plotList = topPlot.getSubplots()
else:
plotList = [topPlot]
for plot in plotList:
datasetCount = plot.getDatasetCount()
for dsIndex in xrange(datasetCount):
dataset = plot.getDataset(dsIndex)
columnNames = list(dataset.getDataSetForSeries(0).getColumnNames())[1:]
renderer = plot.getRendererForDataset(dataset)
# Create a shape to use for hiding a series shape.
hiddenShape = renderer.getSeriesShape(0)
hiddenShape.height = 0
hiddenShape.width = 0
hiddenShape.x = 0
hiddenShape.y = 0
for seriesIndex, seriesName in enumerate(columnNames):
if seriesName in seriesFilter:
renderer.setSeriesShape(seriesIndex, hiddenShape)