How do I complete remove the draw value on bar chart using iOS charts with swift 3 - swift

I am trying to remove the bottom draw values (in black) on my X axis. I tried self.chartActual.drawValueAboveBarEnabled = false but all that does is move the values to below the top of the bar. I also tried self.chartActual.xAxis.drawLabelsEnabled = false but that hides my top labels.
How do I remove the drawvalue on the X axis using ios-charts?

let datamore = BarChartData()
let ds12 = BarChartDataSet(values: dataEntries, label: nil)
datamore.addDataSet(ds12)
datamore.setDrawValues(false)
I needed the last line AFTER adding the data.

Related

How to rotated left axis label in stack bar charts?

I am using Charts library. I want to rotate left axis label to 90 degrees. How can I do that? Please help me.
I am able to rotate xAxis label. This is how I rotate xAxis:
barChart.xAxis.labelPosition = XAxis.LabelPosition.topInside
barChart.xAxis.labelRotationAngle = kXAxisLabelRotationAngleForShareOfVoiceByDrugs
And for leftAxis:
barChart.leftAxis.valueFormatter = IndexAxisValueFormatter(values:hotTopicsAndWeakSignalsModel.barChartDrugNames)
barChart.leftAxis.labelPosition = .outsideChartr
How can set rotation to leftAxis?
To rotate the xAxis Label, you need to do this:
barChart.xAxis.labelRotationAngle = YOUR_ANGLE
like
barChart.xAxis.labelRotationAngle = 90.0

iOS Charts Pie Chart Size

I am using iOS Charts with Swift 3.
I have a 100 x 100 PieChartView that renders the pie chart, but it's not filling the view (an NSView, to be precise). The gray box is the view and there's a large gap between the pie and the edge.
I have confirmed that the view is 100 x 100:
print(graph.frame) //<-- (25.0, 65.0, 100.0, 100.0)
So I assume there is something I need to configure in the pie chart to allow it to be the full size in the view. Here's what I've tried so far to no avail:
graph.holeRadiusPercent = 0.7
graph.transparentCircleRadiusPercent = 0
graph.legend.enabled = false
graph.chartDescription?.enabled = false
graph.minOffset = 0
Any ideas?
Found it! It turns out my graph was rendering the values in the pre-selection state. If I clicked on a pie segment, it would grow larger.
So by setting this property, the graph fills the available space:
ds.selectionShift = 0 //'ds' is my PieChartDataSet
I hope that helps someone else.

Change origin position in ios-charts

Has anyone tried setting a custom origin (0,0) for ios-charts?
The default origin is at the bottom left corner, I want my origin at the top left corner, is this possible? (see images for reference)
default
what i want to achieve
You can change label position for XAxis instance object using your chartView object.
//self.chartView is the ChartView instance.
let xAxis : XAxis = self.chartView.xAxis
xAxis.labelPosition = .top
It's quite simple.
First, as another answer said, change xAxis.labelPosition = .top.
Then, set Y axis self.chartView.leftAxis.inverted = true.
That`s all!

How do I add a units label to a ILNumerics Colorbar

I would like to display the units in text for the values displayed on the colorbar. I have a colorbar added to my ILSurface and I'd like to show my units in text on the color bar along with the range.
Edit: I want to display text at the bottom of the color bar below the bottom tick just the one label.
I was able to get this to work this way
new ILColorbar()
{
Children = { new ILLabel("nm") {Position = new Vector3(.2f,.98f,0) } }
}
I have to say the Position coordinates are not very intuitive. I had to basically adjust the numbers by trial and error until it fit. I knew that the values range 0..1 so the X value was 1 at the bottom but I wanted it up from the border. And the Y value would need to be indented in some but I wasn't sure what was a good value but .2 works.
You can access the axis of ILColorbar and configure it in the usual way. Use the LabelTransformFunc on the ticks to set your own label text. You can use the default transform func and add your unit string.
Example:
var cb = scene.First<ILColorbar>();
cb.Axis.Ticks.LabelTransformFunc = (ind, val) =>
{
return ILTickCollection.DefaultLabelTransformFunc(ind, val) + "nm";
};
You can read more about the axis configuration here:
Axis Configuration
LabelTransformFunc in ApiDoc
Edit:
If only one label is needed, then add a new ILLabel object in ILColorbar group as follows:
new ILColorbar() {
new ILLabel("z(nm)") {
Position = new Vector3(0.5,1,0),
Anchor = new PointF(0.5f,0)
}
}
The ILColorbar area have the relative coordinates 0..1 over the width and the height of the color bar. So we set position x in the middle of the ILColorbar, and position y at the bottom.
The Anchor position is used as relative position in relation to the Position point.
ILLabel Documentation

Microsoft Chart. Legend Appears on Top of X Axis

I created an Microsoft Chart in C# and added the following legend:
Legend legend = new Legend {
Alignment = StringAlignment.Center,
Docking = Docking.Bottom,
Enabled = true,
IsDockedInsideChartArea = false,
TableStyle = LegendTableStyle.Wide,
};
Part of the legend appears on top of the X axis ... Any idea why?
How can I solve this? Can I add a top margin to the legend?
Thank You,
Miguel
In my code I let the Chart create the legend object itself, this is the VB code, but maybe it's useful to you:
aChart.Legends.Clear()
aChart.Legends.Add("Default")
aChart.Legends(0).BorderColor = Color.Black
aChart.Legends(0).Docking = Docking.Bottom
aChart.Legends(0).IsDockedInsideChartArea = False
aChart.Legends(0).TableStyle = LegendTableStyle.Wide
aChart.Legends(0).Alignment = StringAlignment.Center
you need to create a chart area:
p_Chart.ChartAreas.Add(new ChartArea(MAIN_CHART_AREA));
then set both your series and you legend to this area:
legend.DockedToChartArea = MAIN_CHART_AREA;
series.ChartArea = MAIN_CHART_AREA;