Hi everyone,

is there a out of the box way to have 2 columns per X ?

I am tryin to have 2 columns per month, i have seen in the Shinobi galery app something similar but failed so far to replicate.

Thx in advance for any help.

Hi everyone,

is there a out of the box way to have 2 columns per X ?

I am tryin to have 2 columns per month, i have seen in the Shinobi galery app something similar but failed so far to replicate.

Thx in advance for any help.

Even after chaging the the xAxisStyle to:

```
SChartCategoryAxis *xAxis = [SChartCategoryAxis new];
SChartAxisStyle *xAxisStyle = [SChartAxisStyle new];
[xAxisStyle setInterSeriesPadding:@(0.0f)];
[xAxisStyle setInterSeriesSetPadding:@(0.0f)];
[xAxis setStyle:xAxisStyle];
```

the bars width doesnt change, i know it has somethign to do with the way shinobi calculates with, but cant figure what i need to change in order to make them larger.

Taken from another post on the shiboni forums …

*Simon*

Hi folks - I hope I can clarify this for you:

We calculate a width in data terms for the bars or columns in a series by examining the minimum distance between any two datapoints along the Y or X axis, respectively. We also take the number of series of bar/column series, and any stacking, into account and add a little spacing by default.

You can configure the amount of spacing between bars/columns and sets of bars/columns (those which are ‘on the same datapoint’) by setting the interSeriesPadding and interSeriesSetPadding properties on the axis’ style object, where 0.f is no padding and 1.f is all padding.

@tonyarnold as you’ve discovered, where the calculated width is very small and the axis range very large, you can run into issues with thin or invisible bars/columns. I’ve sent you an email in the last few minutes which I hope will help in your case.

@giebler wider-than-desired bars/columns are more easily fixed - increasing the padding values should allow you to tweak their widths.

Hope this helps!

Simon

Hi Moonlace,

Is the problem that your bars aren’t centered on the X-axis tick labels? If so, can I ask how many series you are adding to your chart? (I can see two bars, but there might be more series with 0 value )

Thanks,

Jan

Not quite i have a print of all the points that are being created.

```
services[2329:c07] { index=0, x=P1 - CRITICAL, y=100, selected=N }
2013-08-02 15:16:05.372 managed-services[2329:c07] { index=0, x=P1 - CRITICAL, y=80, selected=N }
2013-08-02 15:16:05.372 managed-services[2329:c07] { index=0, x=P2 - HIGH, y=80, selected=N }
2013-08-02 15:16:05.373 managed-services[2329:c07] { index=0, x=P2 - HIGH, y=100, selected=N }
2013-08-02 15:16:05.373 managed-services[2329:c07] { index=0, x=P3 - MEDIUM, y=100, selected=N }
2013-08-02 15:16:05.374 managed-services[2329:c07] { index=0, x=P3 - MEDIUM, y=100, selected=N }
2013-08-02 15:16:05.374 managed-services[2329:c07] { index=0, x=P4 - LOW, y=90, selected=N }
2013-08-02 15:16:05.375 managed-services[2329:c07] { index=0, x=P4 - LOW, y=100, selected=N }
```

I think that problem is that i have 2 bars to the same X, and somehow it makes the width calculation give a small value,

also because the spacing between each pair is the same.

Hi MrX,

If you’re using the same code as in your post at Swift: SChartColumn Change Legend Label then I think the reason for your large gaps is that you’re using a different series for each datapoint. If you change it to use a single series then the gaps will disappear.

Alison

Hi aclarke,

Yes my code is same with my question before. I dont fully understand with `single series`

.but i need 8 series which regarding with my data. But i think same that there are a gaps or empty series in there because when i debug it, `func sChart(_ chart: ShinobiChart, dataPointAt dataIndex: Int, forSeriesAt seriesIndex: Int) -> SChartData { ..}`

is execute many times

Hi MrX,

The easiest way to explain is probably to use an example:

This chart consists of 3 series (Reading, Math, Writing). Each series contains 10 data points, i.e. the `numberOfSeries(in chart: ShinobiChart)`

method returns 3, and the `sChart(_ chart: ShinobiChart, numberOfDataPointsForSeriesAt seriesIndex: Int)`

method returns 10.

In your case, looking at the code from your previous post, it looks like you require 1 series containing 4 data points, so your `numberOfSeries(in chart: ShinobiChart)`

method would return 1, and your `sChart(_ chart: ShinobiChart, numberOfDataPointsForSeriesAt seriesIndex: Int)`

method would return 4.

It’s normal that `sChart(_ chart: ShinobiChart, dataPointAt dataIndex: Int, forSeriesAt seriesIndex: Int)`

is executed many times: it is called once for each data point in each series, so in the image I posted it would be executed 30 times.

Does that help you?

Alison

Hi aclarke,

Thanks for great answer, but its make my chart only shown one bar only (3 series and 4 datapoint). Below my code at `func sChart(_ chart: ShinobiChart, dataPointAt dataIndex: Int, forSeriesAt seriesIndex: Int) -> SChartData { }`

:

```
let dataPoint = SChartDataPoint()
switch seriesIndex {
case 0:
let xValue = "Departed"
let yValue = (dataOverview["departed1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break
case 1 :
let x2Value = "Departed"
let y2Value = (dataOverview["departed2"] as! Int)
dataPoint.xValue = x2Value
dataPoint.yValue = y2Value
break
case 2:
let xValue = "Departing"
let yValue = (dataOverview["departing1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break
case 3:
let xValue = "Departing"
let yValue = (dataOverview["departing2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break
case 4:
let xValue = "Arriving"
let yValue = (dataOverview["arriving1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break;
case 5:
let xValue = "Arriving"
let yValue = (dataOverview["arriving2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break;
case 6:
let xValue = "Arrived"
let yValue = (dataOverview["arrived1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break;
case 7:
let xValue = "Arrived"
let yValue = (dataOverview["arrived2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
break;
default: ()
}
return dataPoint
```

Do i do a mistake?

Edit *Solved :

```
if(seriesIndex == 0 ) {
if dataIndex == 0 {
xValue = "Departed"
yValue = (dataOverview["departed1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 1 {
xValue = "Departing"
yValue = (dataOverview["departing1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 2 {
xValue = "Arriving"
yValue = (dataOverview["arriving1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 3 {
xValue = "Arrived"
yValue = (dataOverview["arrived1"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
}
else if (seriesIndex == 1) {
if dataIndex == 0 {
xValue = "Departed"
yValue = (dataOverview["departed2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 1 {
xValue = "Departing"
yValue = (dataOverview["departing2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 2 {
xValue = "Arriving"
yValue = (dataOverview["arriving2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
else if dataIndex == 3 {
xValue = "Arrived"
yValue = (dataOverview["arrived2"] as! Int)
dataPoint.xValue = xValue
dataPoint.yValue = yValue
}
}
```

Thanks In Advance