What did I do?
Created a line chart project with linear mode. For that followed the demonstration code base https://github.com/danielgindi/Charts. So for plotting of positive x values and positive y values. But when I have plotted positive "X" values and negative and positive "Y" values then it seems the (0,0) co-ordinate of the plotted graph is not the same as actual (0,0) co-ordinate. Plotted the chart as follows:
ChartDataEntry(x: 0.0, y: 8.0) ChartDataEntry(x: 1.0, y: 42.0) (ChartDataEntry(x: 3.0, y: 0.0) (ChartDataEntry(x: 7.0, y: 45.0) (ChartDataEntry(x: 8.0, y: 28.0) (ChartDataEntry(x: 10.0, y: 0.0)
What did I expect to happen?
Expected that the limit line at 0 x-axis and the actual plot 0 x-axis has to be same.
What happened instead?
There is a 12-14 pixels gap between the 0 x-axis and the actual plot 0 x-axis. Please find the below screen shot :
Could you please help if anybody tried the negative line chart plotting using this danielgindi/Charts SDK. Thank you in advance for your help.
Charts version/Branch/Commit Number: : v4.1.0
Xcode version: 13.0
Swift version: Swift 5
Tried the above explained plot using Chart SDK. Added the limit lines as well:
let ll1 = ChartLimitLine(limit: 100, label: "")
ll1.lineWidth = 0.3
ll1.lineColor = .gray
ll1.lineDashLengths = [0, 0]
ll1.labelPosition = .rightBottom
ll1.valueFont = .systemFont(ofSize: 5)
let ll2 = ChartLimitLine(limit: 0, label: "")
ll2.lineWidth = 0.3
ll2.lineColor = .gray
ll2.lineDashLengths = [0, 0]
ll2.labelPosition = .rightTop
ll2.valueFont = .systemFont(ofSize: 5)
let ll3 = ChartLimitLine(limit: -100, label: "Lower Limit")
ll3.lineWidth = 0.3
ll3.lineColor = .gray
ll3.lineDashLengths = [0, 0]
ll3.labelPosition = .rightTop
ll3.valueFont = .systemFont(ofSize: 5)
DataSet default to depend on left axis, you need to change the axisDependency to right axis