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

Can not see the top half of the label of Y axis and the right half of the label of X axis #37

Closed
cafish opened this issue Sep 12, 2015 · 4 comments

Comments

@cafish
Copy link

cafish commented Sep 12, 2015

Hi,

I am using the simple code as you provided to generate the chart. But the chart seems be cut by the edge of the frame. (I can not see the top half of 200 and right half of 100). Could you help to figure out the problem? thanks

error

import UIKit
import SwiftCharts

class ChartViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //new code
        self.view.addSubview(chart.view)

    }

    let chartConfig : ChartConfigXY!

    let chart : LineChart!

    required init(coder aDecoder: NSCoder) {
        self.chartConfig = ChartConfigXY(
            xAxisConfig: ChartAxisConfig(from: 0, to: 100, by: 20),
            yAxisConfig: ChartAxisConfig(from: 0, to: 200, by: 40)
        )

        self.chart = LineChart(
            frame: CGRectMake(10, 80, 300, 200),
            chartConfig: chartConfig,
            xTitle: "Time (s)",
            yTitle: "Pressures (cm H2O)",
            lines: [
                (chartPoints: [(12.0, 50.6), (14.2, 85.1), (17.3, 123.0), (18.1, 135.5), (94.0, 148.0)], color: UIColor.redColor()),
                (chartPoints: [(12.0, 52.6), (14.2, 59.1), (17.3, 61.0), (18.1, 90.5), (94.0, 113.0)], color: UIColor.blueColor())
            ]
        )
        super.init(coder: aDecoder)
    }
}
@ivnsch
Copy link
Owner

ivnsch commented Sep 13, 2015

You can pass to ChartConfigXY a chartSettings parameter, where you can set top and trailing values (this is the space between the axis end and view's edge). See example

@ivnsch
Copy link
Owner

ivnsch commented Oct 6, 2015

Closing due to inactivity, if you have further questions/issues, feel free to comment.

@ivnsch ivnsch closed this as completed Oct 6, 2015
@ghost
Copy link

ghost commented Oct 30, 2015

The example link seems dead, would you provide another one or paste some code here? Thanks!

@ivnsch
Copy link
Owner

ivnsch commented Oct 30, 2015

let chartSettings = ChartSettings()
chartSettings.leading = 10
chartSettings.top = 10
chartSettings.trailing = 10
chartSettings.bottom = 10
...

let chartConfig = ChartConfigXY(
    chartSettings: chartSettings,
    ...
)

Corrected link also https://github.com/i-schuetz/SwiftCharts/blob/master/Examples/Examples/Convenience/ConvenienceLinesExample.swift

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

No branches or pull requests

2 participants