Robert Haworth
Robert Haworth

Reputation: 448

Modify the vertical label position for y-axis with ShinobiChart

I have a ColumnSeries chart that I want to represent the majorTickLabel as if hovering above the majorGridLine but I don't see a straight forward way of controlling where the label draws beyond what I currently have which achieves insetting the label so that it 'hovers' above the graph.

Is this functionality missing from the API? If so, any suggestions on where to look at to achieve this?

Below is my current y-axis implementation

let yAxis = SChartNumberAxis()
yAxis.style.majorGridLineStyle.showMajorGridLines = true
yAxis.rangePaddingHigh = 500
yAxis.discontinuousTickLabelClipping = SChartDiscontinuousTickLabelClippingHigh
yAxis.axisPosition = SChartAxisPositionReverse
yAxis.style.majorTickStyle.tickGap = -45
goalChart.yAxis = yAxis

UPDATE- ANSWER BELOW

Thanks Sammy, simply offsetting the tickLabel resolved my issue. Below is a copy of the solution used.

@objc func sChart(chart: ShinobiChart!, alterTickMark tickMark: SChartTickMark!, beforeAddingToAxis axis: SChartAxis!) {
        if !axis.isXAxis() {
            if let label = tickMark.tickLabel {
                label.frame.offset(dx: 0, dy: -8)
            }
        }
}

Upvotes: 1

Views: 685

Answers (1)

sammyd
sammyd

Reputation: 893

The tickGap property on SChartTickStyle gives you some control over the position of the tick mark label relative to the tick mark itself. It seems that you have discovered this, and that it doesn't offer the power that you require.

For more fine-grained control, you should look at implementing the SChartDelegate protocol, specifically the following method:

- (void)sChart:(ShinobiChart *)chart alterTickMark:(SChartTickMark *)tickMark
                                beforeAddingToAxis:(SChartAxis *)axis

This gives you an opportunity to change the tick mark before it gets added to the axis. You can get hold of the label via the tickLabel property. For further details on the other properties available to you during this method call, check out the documentation for SChartTickMark.

sam

Upvotes: 1

Related Questions