Setting Chart X axis min tick size?

How could I set a chart so that the tick size is every full 1.0? For instance, I have a chart with the X-axis being weeks of the year. Weeks such as 17, 18, 19 are displayed 17, 17.5, 18, 18.5, 19, 19.5 across the X-axis of the chart.

Thanks
Casey

No, you can’t set the tick units for the x-axis. You can only do it for the y-axis.

Any thoughts of a possible work around? I can resize the chart smaller till the half marks go away.
Thanks
Casey

Are you married into using a line chart? A bar chart would put things into categories for you.

I could do that, change to a bar chart and I do see that works just fine with the exception of that the line chart automatically sorted the dataset ascending for me.

Could you please help explain the dataset sorting ability?

system.dataset.sort(dataset, keyColumn [, ascending])
Parameters
Dataset dataset - The dataset to sort.
String keyColumn - The index or column name of the column to sort on.
boolean ascending - True for ascending order, False for descending order. [optional]

I have tried using the following, yet I get an error that name WEEK doesn’t exist. If I change from the name of the column to the int of it… 0, then I get a 1st arg can’t be coerced to com.ind…

if event.propertyName == “dbbrowse”:
dbbrowse = system.dataset.toPyDataSet(event.newValue)
newData2 = []

for row in dbbrowse:
newData2.append([row[2], row[3]])

event.source.newData2 = system.dataset.toDataSet([“WEEK”, “LBS PMH”], newData2)
system.dataset.sort(newData2, WEEK [,True])

Thanks,
Casey

Try:

if event.propertyName == "dbbrowse":
  dbbrowse = system.dataset.toPyDataSet(event.newValue)
  rows = []

  for row in dbbrowse:
    rows.append([row[2], row[3]])

  data = system.dataset.toDataSet(["WEEK", "LBS PMH"], rows)
  system.dataset.sort(data, "WEEK" , 1)

I think you were getting confused by having the optional parameters in square brackets in the documentation and true being represented by a non-zero number.

Yes that was confusing me. I just tried that, now no errors, but also no data in the dataset. I also tried changing the syntax within the existing script and same result. No error, but also no result within the dataset, the data stayed sorted the same way.

Thanks
Casey

[quote=“cswett”]Yes that was confusing me. I just tried that, now no errors, but also no data in the dataset. I also tried changing the syntax within the existing script and same result. No error, but also no result within the dataset, the data stayed sorted the same way.

Thanks
Casey[/quote]

Sorry about that. sort actually returns a sorted dataset instead of manipulating the referenced dataset.

sortedData = system.dataset.sort(data, "WEEK" , 1)

I wonder what I’m still missing, I’m getting:

File “event:propertyChange”, line 9, in
TypeError: sort(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.Dataset

Line 9: sortedData = system.dataset.sort(newData2, “WEEK” , 1)

----Under the root container, I have customer properties configured for three datasets (dbbrowse, newData2, and sortedData).

if event.propertyName == “dbbrowse”:
dbbrowse = system.dataset.toPyDataSet(event.newValue)
newData2 = []

for row in dbbrowse:
newData2.append([row[1], row[2], row[3]])

event.source.newData2 = system.dataset.toDataSet([“WEEK”, “LBS PMH”, “GOAL”], newData2)
sortedData = system.dataset.sort(newData2, “WEEK” , 1)

I was able to get this working by using the expression sort functionality and then choosing Expression under the data binding for each chart.

sortDataset({Root Container.newData2}, 0, true)

I would still like to figure out what I was doing wrong under the scripting, but this gets me running.

Thanks,
Casey

I was also able to come up with a way to keep the mid-tick size graduations from showing up. I just increased the size of the font for the tick labels. Now I can make the line chart as large as I want without the other ticks showing up.