Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoidFirstLastClippingEnabled Still be clipped in CombinedChartView #876

Closed
bakso opened this issue Mar 24, 2016 · 7 comments
Closed

avoidFirstLastClippingEnabled Still be clipped in CombinedChartView #876

bakso opened this issue Mar 24, 2016 · 7 comments

Comments

@bakso
Copy link

bakso commented Mar 24, 2016

I 've tried _chartView.xAxis.avoidFirstLastClippingEnabled = true, not use

I seem that the last point was not shown still

@bakso
Copy link
Author

bakso commented Mar 24, 2016

I am sure that the last xVal was putted in the last xVals:

for (var i : Int = 0; i < entryCount; i++) {
            let item = entries![i]
            let minute = String(item[0].stringValue)
            let minuteArr = minute.componentsSeparatedByString(":")
            var xVal = minuteArr[0]+":"+minuteArr[1]
            if xVal == "13:00" && (type == "sh" || type == "sz") {
                xVal = "11:30/13:00"
            }
            xVals.append(xVal)
            if i == entryCount-1 {
                print(xVals[i]) // here print 15:00 but the last entry still invisible
            }

@bakso
Copy link
Author

bakso commented Mar 26, 2016

image

image

The latest label was not shown, as if is being clipped or eaten

@liuxuan30
Copy link
Member

have you checked your xAxis.axisLabelModulus? Whether to render the text is in x axis renderer's public func drawLabels(context context: CGContext, pos: CGFloat, anchor: CGPoint)

you will see how avoidFirstLastClippingEnabled is used:

for i in self.minX.stride(to: min(self.maxX + 1, xAxis.values.count), by: xAxis.axisLabelModulus)
{
    if (xAxis.isAvoidFirstLastClippingEnabled)
    {
        if (i == xAxis.values.count - 1 && xAxis.values.count > 1)
         {
         }
        else if (i == 0)
        {
        }
    } 
}

So in your case, the last value never satisfy the condition. e.g last i is not xAxis.values.count - 1, this will be caused if your axisLabelModulus is not 1. And in your chart, it is not 1, because not every label is drawn.
BTW, avoidFirstLastClippingEnabled means "if set to true, the chart will avoid that the first and last label entry in the chart "clip" off the edge of the chart". It is not used to guarantee the first and last is always rendered. It just avoids being clipped.

@bakso
Copy link
Author

bakso commented Mar 26, 2016

@liuxuan30 Let me have a check, thank you and have a nice vestval!

@saxxi
Copy link

saxxi commented Sep 13, 2016

Hi, I'm also not able to show the last label on the xAxis.

Example:

  • I have 50 data points
  • I'd like to to show the first [0], a mid point [24] and the last [49] labels

Here's a set of different attempts:

  • view.xAxis.setLabelsToSkip(25)
  • view.xAxis.setLabelsToSkip(24)
  • view.xAxis.axisLabelModulus = 24

(I'm using avoidFirstLastClippingEnabled which is fitting only the first label)

I followed Stackoverflow and apparently the Android version have the same issue.

Thank you!

@liuxuan30
Copy link
Member

@saxxi try v3 first. and don't reply a closed issue.. hard to track

@29satnam
Copy link

29satnam commented Jun 6, 2018

I still have this issue, any solution guys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants