ios - 如何在烛台图表的蜡烛顶部和底部绘制自定义视图
问题描述
我正在为烛台图使用 iOS图表库,我无法找到任何方法来绘制自定义视图,即图像库中显示的三角形。
我想根据标志在蜡烛的顶部和底部显示三角形(视图)。
如果这在Charts库中是不可能的,请让我知道我可以实现此目的的备用库。
{
chartView.delegate = self
chartView.chartDescription?.enabled = true
chartView.drawBordersEnabled = false
chartView.drawGridBackgroundEnabled = false
chartView.xAxis.labelTextColor = .white
chartView.rightAxis.labelTextColor = .white
chartView.dragEnabled = true
chartView.setScaleEnabled(true)
chartView.pinchZoomEnabled = true
chartView.drawMarkers = true
chartView.legend.enabled = false
chartView.leftAxis.enabled = false
chartView.leftAxis.spaceTop = 0.3
chartView.leftAxis.spaceBottom = 0.3
chartView.leftAxis.axisMinimum = 0
chartView.rightAxis.enabled = true
chartView.rightAxis.axisLineColor = .primaryBlue
chartView.drawGridBackgroundEnabled = false
let candleResponse = MasterData.shared.candleResponse
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "h:mm a"
let dates = candleResponse
.map { Date(timeIntervalSince1970: ($0.first ?? 0)/1000) }
.map { dateFormatter.string(from: $0) }
chartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: dates)
chartView.xAxis.labelPosition = .bottom
let yVals1 = (0..<candleResponse.count).map { (i) -> CandleChartDataEntry in
return CandleChartDataEntry(x: Double(i),
shadowH: candleResponse[i][2],
shadowL: candleResponse[i][3],
open: candleResponse[i][1],
close: candleResponse[i][4])
}
let set1 = CandleChartDataSet(entries: yVals1)
set1.setDrawHighlightIndicators(true)
set1.drawVerticalHighlightIndicatorEnabled = true
set1.drawHorizontalHighlightIndicatorEnabled = true
set1.axisDependency = .right
set1.setColor(UIColor(white: 80/255, alpha: 1))
set1.drawIconsEnabled = true
set1.shadowColor = .darkGray
set1.shadowWidth = 0.7
set1.decreasingColor = .red
set1.decreasingFilled = true
set1.increasingColor = UIColor(red: 122/255, green: 242/255, blue: 84/255, alpha: 1)
set1.increasingFilled = true
set1.neutralColor = .blue
let data = CandleChartData(dataSet: set1)
data.setDrawValues(false)
chartView.data = data
}
解决方案
推荐阅读
- opengl - 在 cygwin 中编译 OpenGL 程序失败
- aws-fargate - 如何将 Linux 功能 SYS_NICE 和 DAC_READ_SEARCH 添加到 AWS Fargate 中的容器?
- javascript - 通过经验找到最接近的水平
- database - 检测导致数据库阻塞会话的特定脚本
- sql - 尝试添加空格时使用 concat 时出错?
- java - Spring JPA 在分页存储库中按外键选择
- discord - 睡眠功能在 discord.py 中的行为不像应有的那样
- r - 如何通过更改数据的配置来删除数据帧的 NA?
- dart - 将字符串转换为由多个字符组成的数字的列表
- assembly - 为什么有必要在除以 2 的幂的有符号除法上添加一个偏差?