You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 2 charts , a line chart and a bar chart. both have pinchZoom disabled and the barChart is overlapping the lineChart.
You can see in the images below... the barChart won't sit flush to the bottom of the screen.
However on the 1m data the bar Chart does sit flush with the bottom.
What is causing this gap below the barchart when I load new data into it? the more data I put into a barChartDataSet the more off the bar chart is from sitting on the bottom of the screen
Here is some code showing how I setup these charts.
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.whiteColor()
//Setup linechart and add to main View
lineChartView.frame = CGRectMake(0, LINECHART_HEADER_HEIGHT, view.frame.width, view.frame.height - LINECHART_HEADER_HEIGHT)
lineChartView.delegate = self;
lineChartView.descriptionText = "";
lineChartView.noDataTextDescription = "You need to provide data for the chart.";
lineChartView.dragEnabled = true;
lineChartView.setScaleEnabled(true)
//Disable pinchZoom
lineChartView.pinchZoomEnabled = false;
lineChartView.scaleXEnabled = false
lineChartView.scaleYEnabled = false
lineChartView.drawGridBackgroundEnabled = false;
// lineChart.autoScaleMinMaxEnabled = true
// x-axis limit line
let llXAxis:ChartLimitLine = ChartLimitLine(limit: 10, label: "Index 10")
llXAxis.lineWidth = 4.0;
llXAxis.lineDashLengths = [(10.0), (10.0), (0.0)];
llXAxis.labelPosition = ChartLimitLine.ChartLimitLabelPosition.RightBottom
llXAxis.valueFont = UIFont.systemFontOfSize(10)
//[_chartView.xAxis addLimitLine:llXAxis];
let ll1:ChartLimitLine = ChartLimitLine(limit: 130, label: "Upper Limit")
ll1.lineWidth = 4.0;
ll1.lineDashLengths = [5.0, 5.0];
ll1.labelPosition = ChartLimitLine.ChartLimitLabelPosition.RightTop;
ll1.valueFont = UIFont.systemFontOfSize(10.0);
let ll2:ChartLimitLine = ChartLimitLine(limit: -30.0, label: "Lower Limit")
ll2.lineWidth = 4.0;
ll2.lineDashLengths = [5.0, 5.0];
ll2.labelPosition = ChartLimitLine.ChartLimitLabelPosition.RightBottom;
ll2.valueFont = UIFont.systemFontOfSize(10.0)
let leftAxis:ChartYAxis = lineChartView.leftAxis;
leftAxis.removeAllLimitLines()
// leftAxis.addLimitLine(ll1)
// leftAxis.addLimitLine(ll2)
// leftAxis.axisMaxValue = 220.0;
// leftAxis.axisMinValue = -50.0;
leftAxis.gridLineDashLengths = [5.0, 5.0];
leftAxis.drawZeroLineEnabled = false;
leftAxis.drawLimitLinesBehindDataEnabled = true;
lineChartView.rightAxis.enabled = false;
lineChartView.leftAxis.enabled = false;
lineChartView.xAxis.enabled = false;
lineChartView.legend.enabled = false
lineChartView.leftAxis.labelPosition = ChartYAxis.YAxisLabelPosition.InsideChart
lineChartView.setViewPortOffsets(left: 0, top: 0, right: 0, bottom: 0)
//Set marker for line chart
let marker = BalloonMarker(color: UIColor.blueColor(), font: UIFont.systemFontOfSize(12), insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0))
marker.minimumSize = CGSizeMake(50, 40);
marker.color = UIColor(red: 251/255, green: 73/255, blue: 90/255, alpha: 0.6)
lineChartView.marker = marker
lineChartView.legend.form = ChartLegend.ChartLegendForm.Line
//Setup barchart and add to main View
barChartView.frame = CGRectMake(0, view.frame.height/2, view.frame.width, view.frame.height/2)
barChartView.delegate = self;
barChartView.descriptionText = "";
barChartView.noDataTextDescription = "You need to provide data for the chart.";
barChartView.dragEnabled = true;
barChartView.setScaleEnabled(true)
//Disable pinchZoom
barChartView.pinchZoomEnabled = false;
barChartView.scaleXEnabled = false
barChartView.scaleYEnabled = false
barChartView.drawGridBackgroundEnabled = false;
barChartView.rightAxis.enabled = false;
barChartView.leftAxis.enabled = false;
barChartView.xAxis.enabled = false;
barChartView.legend.enabled = false
barChartView.alpha = 0.6
barChartView.setViewPortOffsets(left: 0, top: 0, right: 0, bottom: 0)
informationLabel.text = ""
//DATA request
loadChartWithRange(range: .OneDay)
`
//CandleChart properties:
let candleChartDataSet = CandleChartDataSet(yVals: self.candleChartDataEntries, label: "")
candleChartDataSet.axisDependency = ChartYAxis.AxisDependency.Left
candleChartDataSet.setColor(UIColor(white: 80/255, alpha: 1.0))
candleChartDataSet.highlightLineDashLengths = [5.0,2.5];
candleChartDataSet.highlightColor = UIColor.lightGrayColor()
candleChartDataSet.shadowColor = UIColor.darkGrayColor()
candleChartDataSet.valueTextColor = UIColor.orangeColor()
candleChartDataSet.drawValuesEnabled = false
candleChartDataSet.shadowWidth = 0.7
candleChartDataSet.decreasingColor = UIColor.redColor()
candleChartDataSet.decreasingFilled = true;
candleChartDataSet.increasingColor = UIColor(red: 122/255, green: 242/255, blue: 84/255, alpha: 1)
candleChartDataSet.increasingFilled = false;
candleChartDataSet.neutralColor = UIColor.blueColor()
//Data to add to chart
let candleChartData = CandleChartData()
candleChartData.addDataSet(candleChartDataSet)
//LineChart properties:
let lineChartDataSet = LineChartDataSet(yVals: self.lineChartDataEntries, label: "")
// set1.lineDashLengths = [5.0, 2.5];
lineChartDataSet.highlightLineDashLengths = [5.0,2.5];
lineChartDataSet.highlightColor = UIColor.lightGrayColor()
//Toggle color depending on price perfomrnace
if self.lineChartDataEntries.first?.value > self.lineChartDataEntries.last?.value {
lineChartDataSet.setColor(UIColor.redColor())
} else if self.lineChartDataEntries.last?.value > self.lineChartDataEntries.first?.value {
lineChartDataSet.setColor(UIColor.greenColor())
} else if self.lineChartDataEntries.first?.value == self.lineChartDataEntries.last?.value {
lineChartDataSet.setColor(UIColor.lightGrayColor())
}
lineChartDataSet.lineWidth = 1.0;
lineChartDataSet.drawCircleHoleEnabled = false;
lineChartDataSet.valueFont = UIFont.systemFontOfSize(9.0);
lineChartDataSet.drawValuesEnabled = false
let gradientColors:NSArray = [ChartColorTemplates.colorFromString("#00ff0000").CGColor,ChartColorTemplates.colorFromString("#ffff0000").CGColor]
let gradient:CGGradientRef = CGGradientCreateWithColors(nil, gradientColors, nil)!
lineChartDataSet.fillAlpha = 1.0;
lineChartDataSet.fill = ChartFill.fillWithLinearGradient(gradient, angle: 90.0)
lineChartDataSet.drawFilledEnabled = true;
lineChartDataSet.drawCubicEnabled = false
lineChartDataSet.drawCirclesEnabled = false
//Data to add to chart
let lineChartData = LineChartData(xVals: self.xVals, dataSets: [lineChartDataSet])
//Barchart properties:
let barChartDataSet = BarChartDataSet(yVals: self.barChartDataEntries, label: "")
//Toggle bar color depending on price Point open and close for specfic time frame
barChartDataSet.setColor(UIColor.greenColor())
barChartDataSet.drawValuesEnabled = false
//Data to add to chart
let barChartData = BarChartData(xVals: self.xVals, dataSets: [barChartDataSet])
//Put all the data from each chart into this combined data store
self.lineChartView.data = lineChartData
self.barChartView.data = barChartData
//Redundent for combined chart view
//Data configured! yay! now add chartView to mainView -_-
self.view.addSubview(self.barChartView) //barChart under lineChart
self.view.addSubview(self.lineChartView)
`
The text was updated successfully, but these errors were encountered:
I have 2 charts , a line chart and a bar chart. both have pinchZoom disabled and the barChart is overlapping the lineChart.
You can see in the images below... the barChart won't sit flush to the bottom of the screen.
However on the 1m data the bar Chart does sit flush with the bottom.
What is causing this gap below the barchart when I load new data into it? the more data I put into a barChartDataSet the more off the bar chart is from sitting on the bottom of the screen
Here is some code showing how I setup these charts.
`
// let data:CombinedChartData = CombinedChartData(xVals: self.xVals)
// data.lineData = lineChartData
// data.barData = barChartData
// data.candleData = candleChartData
// self.combinedChartView.data = data
`
The text was updated successfully, but these errors were encountered: