I am using iOS Charts with Swift 3, and I can't figure out how to do a couple things:
I want to remove the margin around the chart. I know the chart goes edge-to-edge in my UI because if I change the chart's background color, it goes all the way to the edge. How do I remove the gap indicated by the red arrows below?
How do I remove the border around the whole graph (note the black arrow)? I already have totalsGraph.drawBordersEnabled = false and it doesn't work. Is there a different option for that?
Thank you!
It is minOffset.
/**
Sets the minimum offset (padding) around the chart, defaults to 10
*/
You can change it as this:
chartView.minOffset = 0
that line is actually axis line.
To hide the all the lines, you can use
totalsGraph.rightAxis.enabled = false
totalsGraph.legend.enabled = false
totalsGraph.leftAxis.enabled = false
totalsGraph.xAxis.labelPosition = .bottom
totalsGraph.xAxis.drawGridLinesEnabled = false
totalsGraph.xAxis.drawAxisLineEnabled = false
I am looking for solution to remove margins as well. I will update my answer when I find it.
Actually the way to do it is like this:
chartView.xAxis.enabled = false
chartView.leftAxis.enabled = false
chartView.rightAxis.enabled = false
chartView.drawBordersEnabled = false
chartView.minOffset = 0
Related
Basically I want to hide dash between the bars from waterfall chart.I am using highcharts iOS wrapper.I can only change type of dash but there is no option to hide or disable the same
You need to set lineWidth property to 0:
let plotOptions = HIPlotOptions()
plotOptions.waterfall = HIWaterfall()
plotOptions.waterfall.lineWidth = 0
options.plotOptions = plotOptions
API Reference: https://api.highcharts.com/ios/highcharts/
i have a tableviewCell containing 2 labels.
The right one has a fixed width and fixed trailing space to superview and the left one a fixed leading space to superview and trailing to right label.
Sometimes i only need the the left label and in this case i want the left one to have a fixed trailing space to superview instead. So, i created a second inactive constraint and do this in my code:
if(entry.right.isEmpty) {
tableCell?.longConstraint.isActive = true
tableCell?.shortConstraint.isActive = false
tableCell?.rightLabel.isHidden = true
} else {
tableCell?.longConstraint.isActive = false
tableCell?.shortConstraint.isActive = true
tableCell?.rightLabel.isHidden = false
}
but when i load the table all displayed cells have the default constraint active and only after scolling out of view and in again, they are displayed correctly.
For an easy way you can embed them inside a horizontal UIStackview and set
self.rightlb.isHidden = true
and it will disappear with no width automatically , also in your current code make sure
tableCell?.layoutIfNeeded()
after you change the constraints
Try adding this code after adjusting constraints programmatically
tableCell?.setNeedsLayout()
tableCell?.layoutIfNeeded()
Hope this works
I'm using ios-charts (https://github.com/danielgindi/Charts). I have a LineChartView with 12 values in the x axis.
This however is far too many to see at the same time, so I want to display only 5 and then let the user drag to the right to see the next.
I've tried this:
let chart = LineChartView()
chart.dragEnabled = true
chart.setVisibleXRangeMaximum(5)
let xAxis = chart.xAxis
xAxis.axisMinValue = 0
xAxis.axisMaxValue = 5.0
xAxis.setLabelsToSkip(0)
But still see all 11 values at the time. How can I only see 5?
I finally got it!
The correct answer is:
chart.setVisibleXRangeMaximum(5)
This however needs to be set after the data has been set in the chart (not in a configure before)
This did the trick for me
You should set the X axis's labelCount property of the chart view.
In objc,like this
_chartView.xAxis.labelCount = 5;
Swift
chartView.xAxis.labelCount = 5
Here is my finding!!
you don't need to really use label count
if you are using DefaultAxisValueFormatter, NEVER use this. a lot of errors pop ! just use no2.
chart.setVisibleXRangeMaximum(number) will do.
please put this after chart data setting here you can see detail
combinedChartView.data = combineData. //this need to come first
combinedChartView.setVisibleXRangeMaximum(2) //after data setting
I need disable some elements from my chart.
I used the iOS-charts library in (Swift 2), however I can't understand how to disable the following:
Hide right and left numbers
Hide description color square
Hide all vertical lines
self.chartView.xAxis.drawGridLinesEnabled = false
self.chartView.leftAxis.drawLabelsEnabled = false
self.chartView.legend.enabled = false
will do the job
self.chartView.drawEntryLabelsEnabled = false
This will hide the label from PieChart and shows only value. Also shows legend with label texts.
For only hide the top one:
graphCell.lineChartView.leftAxis.drawTopYLabelEntryEnabled = false
My question is about a specific Graphs and Charts Building Tool call AMCHARTS. I am using their live editor to build a Graph, and I need to remove the vertical lines (leave the horizontal lines only) from the chart grid.
Is it possible to do so?
thanks,
Just in case someone is still looking for the answer:
//disable horizontal lines
valueAxis.renderer.grid.template.strokeWidth = 0;
//disable vertical lines
categoryAxis.renderer.grid.template.strokeWidth = 0;
just change "categoryAxis"
"categoryAxis": {
"gridThickness": 0
},
Thanks.
If you're looking for a solution on amCharts 4 use the following:
categoryAxis.renderer.grid.template.disabled = true;
See official docs for disabling certain elements
For removing the horizontal lines in the grid ...
"valueAxes":{
"gridThickness":0
},
Just did some research, I'm posting the answer so that other can benefit. This option is in the "Category Axis -> Grid and Fills" Section.
this is a good anseer by adding one more category or value axis to our charts:
https://github.com/amcharts/amcharts4/issues/2866
If you are looking for am5charts, then add
yAxis.get("renderer").grid.template.setAll({
strokeWidth: 0,
visible:false
});
xAxis.get("renderer").grid.template.setAll({
location: 0,
strokeWidth: 0,
visible:false
});