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

請問為何顯示不出座標軸 #1

Open
annann81 opened this issue Oct 22, 2020 · 2 comments
Open

請問為何顯示不出座標軸 #1

annann81 opened this issue Oct 22, 2020 · 2 comments

Comments

@annann81
Copy link

你好
我是個swift初學者
我參考了你的折線圖畫法,但我最後顯示是要在我創建的一份PDF上
我想問你
`func addcharts(imageTop: CGFloat){

    var plotView = PlotView()
    let imageRect = CGRect(x: 0, y: 0,
    width:612, height: 792)
    
   plotView = PlotView(frame: CGRect(x: 0, y: 0, width: 612, height: 792))
    plotView?.backgroundColor = UIColor.gray
    plotView.lineColorArray = [UIColor.red, UIColor.green, UIColor.blue]
    plotView.lineColorTitleArray = ["红", "绿", "蓝"]

    plotView.dataPointArray = [
               [CGPoint(x: 0, y: 0), CGPoint(x: 300, y: 10), CGPoint(x: 600, y: 30), CGPoint(x: 700, y: 20)],
               [CGPoint(x: 0, y: 0), CGPoint(x: 200, y: 10), CGPoint(x: 700, y: 30), CGPoint(x: 800, y: 20)],
               [CGPoint(x: 600, y: 0), CGPoint(x: 900, y: 10), CGPoint(x: 1000, y: 30), CGPoint(x: 1000, y: 60)]
           ]
    
    plotView.drawPlotView()
    plotView.draw(imageRect)
}`

為何我沒辦法顯示座標軸??
我並沒有更動你的程式碼
截圖 2020-10-22 下午4 10 22

@huangzhengguo
Copy link
Owner

你好,你可以试着调整下坐标轴的颜色,是不是由于白色的问题没有显示出来
override func draw(_ rect: CGRect) {
// 获取当前图像上下文
let context = UIGraphicsGetCurrentContext()

    context?.setStrokeColor(UIColor.white.cgColor)  // 这里默认是白色,可以调整为其它颜色试试

@huangzhengguo
Copy link
Owner

@annann81 你看下调整下坐标轴颜色是否可以

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