Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Spline and SplineArea Series on same chart with Swift
posted

I'm working on a test project with different charts and one chart I'm having issues with right now is a single chart with 2 spline area series and 1 spline series. I use Swift as my main language as well so I'm trying to keep this as a swift project and so far no matter how I try only one series shows up on the chart view (usually the last one added). I'm sure I'm missing something or don't have something configured correctly but didn't find anything in the documentation that helped. Here's the code that I've been working with 

func setupArea1Series(time1 : Date, time2 : Date) {

        let dataSource = IGCategoryDateSeriesDataSourceHelper()

        dataSource.dates = [time1, time2]

        dataSource.values = [0, 1]

        let splineSeries = IGSplineAreaSeries(key: "series1")

        splineSeries.xAxis = self.dateAxis

        splineSeries.yAxis = self.valueAxis

        splineSeries.dataSource = dataSource

        self.chartView.addSeries(splineSeries)

    }

    

    func setupSplineSeries(time3 : Date, time4 : Date, time5 : Date) {

        let dataSource = IGCategoryDateSeriesDataSourceHelper()

        dataSource.dates = [time3, time4, time5]

        dataSource.values = [2, 3, 2]

        let splineSeries = IGSplineSeries(key: "series2")

        splineSeries.xAxis = self.dateAxis

        splineSeries.yAxis = self.valueAxis

        splineSeries.dataSource = dataSource

        self.chartView.addSeries(splineSeries)

    }

    

    func setupSplineAreaSeries2(time6 : Date, time7 : Date) {

        let dataSource = IGCategoryDateSeriesDataSourceHelper()

        dataSource.dates = [time6, time7]

        dataSource.values = [4, 0]

        let splineSeries = IGSplineAreaSeries(key: "series3")

        splineSeries.xAxis = self.dateAxis

        splineSeries.yAxis = self.valueAxis

        splineSeries.dataSource = dataSource

        self.chartView.addSeries(splineSeries)

    }


func setupChartView() {

self.dateAxis = IGCategoryDateTimeXAxis(key: "xAxis")

        self.dateAxis.minimum = self.selectedDate.startOfDay

        self.dateAxis.maximum = self.selectedDate.endOfDay

        self.valueAxis = IGNumericYAxis(key: "yAxis")

        self.chartView = IGChartView(frame: CGRect(x: 0, y: 8, width: self.view.frame.size.width, height: self.view.frame.size.height-22))

        self.chartView.delegate = self

        self.chartView.add(self.dateAxis)

        self.chartView.add(self.valueAxis)

        self.chartView.isMultipleTouchEnabled = false

        self.sideMenuView.contentView.addSubview(chartView)

    }


The chart setup is called in viewDidLoad and then the series are added with just random times during a given day for each series. If I change the order of the series it only creates the last one added. 

Parents
No Data
Reply
  • 26458
    Offline posted

    Hi,

    This appears to be a bug in the date time axis. I've submitted this issue in our tracking system.

    There are actually a few issues here. One is that series aren't respecting the date ranges you provided and another is the axis doesn't know how to handle series with different number of points.

Children
No Data