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

ChartViewDelegate not called when barChart is out of screen #3165

Closed
ludovicjamet opened this issue Jan 9, 2018 · 3 comments
Closed

ChartViewDelegate not called when barChart is out of screen #3165

ludovicjamet opened this issue Jan 9, 2018 · 3 comments

Comments

@ludovicjamet
Copy link

I got a horizontal scrollView with a BarChartView like :

  • ScrollView
    • ContentView
      • View (with Labels and a button to scrollTo) frame: (0,0, ScreenWidth, ScreenHeight)
      • BarChartView frame: (ScreenWidth, 0, ScreenWidth, ScreenHeight)

On viewDidLoad() I'm calling a setChart methods

func drawActivityChart() {

    activityChart.chartDescription?.text = ""
    activityChart.noDataText = "Aucunes données à afficher"
    activityChart.doubleTapToZoomEnabled = false
    activityChart.drawValueAboveBarEnabled = false
    activityChart.drawBarShadowEnabled = false
    activityChart.dragYEnabled = false
    activityChart.dragXEnabled = false
    activityChart.legend.enabled = false
    activityChart.drawGridBackgroundEnabled = false

    activityChart.xAxis.drawLabelsEnabled = false
    activityChart.xAxis.drawAxisLineEnabled = false
    activityChart.xAxis.drawGridLinesEnabled = false

    activityChart.leftAxis.drawGridLinesEnabled = false
    activityChart.leftAxis.drawAxisLineEnabled = false
    activityChart.leftAxis.drawLabelsEnabled = false

    activityChart.rightAxis.drawGridLinesEnabled = false
    activityChart.rightAxis.drawAxisLineEnabled = false
    activityChart.rightAxis.drawLabelsEnabled = false

    //activityChart.animate(yAxisDuration: 0.5)

    // Draw graph
    let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
    let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]

    var dataEntries: [BarChartDataEntry] = []

    for i in 0..<months.count {
      let dataEntry = BarChartDataEntry(x: Double(i), y: unitsSold[i])
      dataEntries.append(dataEntry)
    }

    let chartDataSet = BarChartDataSet(values: dataEntries, label: nil)
    chartDataSet.drawValuesEnabled = false
    chartDataSet.colors = [UIColor].init(repeating: Default.white.withAlphaComponent(0.2), count: 12)
    chartDataSet.highlightColor = Default.white
    chartDataSet.highlightEnabled = true

    let chartData = BarChartData(dataSets: [chartDataSet])
    chartData.highlightEnabled = true
    activityChart.data = chartData

}

Tap on graph to hilight a bar is not working at all (like all gesture). It the barChart is visible on screen everything works properly of course.

@ludovicjamet ludovicjamet changed the title ChartViewDelegate not called when barChart is dragged out of screen ChartViewDelegate not called when barChart is out of screen Jan 9, 2018
@liuxuan30
Copy link
Member

need some context first. why the bar chart view is out of screen, yet you still can see and tap it?

@ludovicjamet
Copy link
Author

Because graph is on an horizontal scrollview, in page mode. I need to set a custom gesture when the scrollview scrolled to the graph. I'm not sure it's a Charts bug, it's probably a workaround with UIGesture.

@liuxuan30
Copy link
Member

liuxuan30 commented Mar 2, 2018

You don't clear the paradox here. You don't see the bar on the screen yet you can tap it.

Tap on graph to hilight a bar is not working at all (like all gesture). It the barChart is visible on screen everything works properly of course.

This sounds works expected to me. But you should be able to add some breakpoints and debug I believe.

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

2 participants