Drawing chart with showMajorGridLines with large values



I have chart view (Line or Column) and I use showMajorGridLines properties

    // Set x-axis
    let xAxis = SChartCategoryAxis() 
    xAxis.style.majorGridLineStyle.showMajorGridLines = true
    xAxis.style.majorGridLineStyle.dashedMajorGridLines = true
    xAxis.style.majorGridLineStyle.lineWidth = 1
    xAxis.style.majorGridLineStyle.dashStyle = [1]
    xAxis.style.interSeriesPadding = 0.7
    self.xAxis = xAxis
    // Set y-axis
    let yAxis = SChartNumberAxis()

    yAxis.rangePaddingLow = 0.1
    yAxis.rangePaddingHigh = 0.1
    yAxis.style.majorGridLineStyle.showMajorGridLines = true
    yAxis.style.majorGridLineStyle.dashedMajorGridLines = true
    yAxis.style.majorGridLineStyle.lineWidth = 1
    yAxis.style.majorGridLineStyle.dashStyle = [1]
    self.yAxis = yAxis

But if I use values in datapoint that are bigger then a 1000 then chart is not drowned.
There is no error in console, or anything, but chart is simply not drowned. If for example we have smaller data, and then update data to bigger values, old chart remain (old values in chart is shown) but we can’t touch on it. (For example, hair-cross stop working,…)

if I just comment out two lines

  //        yAxis.style.majorGridLineStyle.showMajorGridLines = true
  //        yAxis.style.majorGridLineStyle.dashedMajorGridLines = true

Then everything works like a charm.

Why chart can’t be drowned with bigger values (my datapoint values are around 55 000 000 (money)) with show major gridLines?

I really can’t understand this… can you help me?


Hi Marko,

I’m not sure what you mean by: [quote=“Marko, post:1, topic:1633”]
chart is not drowned

Could you provide a sample with clear steps reproducing your issue?

This would really help us identify the source of your issue.

Kind regards,
Andrew Polkinghorn.


I am sorry for late response.

I solve this myself. The reason was that majorTickFrequency was set to low. (I believe that default is 1? )

The problem is that chart would have to draw to many major ticks on graph so Shinobi doesn’t draw graph at all. (Witch is logical, because it can’t draw 10 000 000 ticks on graph)

The problem was, that I have code, that set majorTickFrequency to right amount but apparently to late in the cycle.

My graph could present graph that have values like 0.1, 0.2, … or 55 000 000, and I don’t know ab front what kind of values will come to the chart. Thats why I do :

on redraw() method I put

yAxis?.majorTickFrequency = Int.max

and then on sChart(chart , alter tickMark, beforeAddingTo axis)

    if axis is SChartNumberAxis {
        axis.majorTickFrequency = Double(axis.dataRange.maximum)/2.0

This will set majorTickFrequency in a way that will always be visible only two tick marks.