I want insert space left and right to prevent value label prevent yAxis value. And remove background line under charts.
How can I do?
Edit
self.lineChart.delegate = self;
self.lineChart.descriptionText = #"";
self.lineChart.drawGridBackgroundEnabled = NO;
self.lineChart.scaleXEnabled = NO;
self.lineChart.scaleYEnabled = NO;
self.lineChart.leftAxis.spaceTop = 0.30f;
On Charts 3.0 you can use...
lineChartView.xAxis.spaceMin = 0.2
lineChartView.xAxis.spaceMax = 0.2
...to add some space on left and right.
To remove the background line under the charts use below code :
_lineChart.yAxis.drawGridLinesEnabled = NO;
_lineChart.xAxis.drawGridLinesEnabled = NO;
To add spacing - you can use Charts 3.0, and adjust xAxis.axisMinimum/xAxis.axisMaximum.
To adjust the background, simply use the UIView's properties of backgroundColor, opaque etc.
To disable the grid - adjust the drawGridLinesEnabled on the axes, as #ashmi123 said.
Related
Hello I am trying to make UISwitch borderWidth smaller, but it doesn't look correct.
All I did is
layer.borderWidth = 0.5
instead of using storyboard try to customise switch programmatically . try using following code as if you change one parameter must adjust radius of switch too. Hope it helps
OnOffSwitch.layer.borderWidth = 1.0;
OnOffSwitch.layer.cornerRadius = 16.0;
OnOffSwitch.layer.borderWidth = 0.5;
OnOffSwitch.layer.cornerRadius = 17.0;
One of my app using Charts library for drawing graphs.
Everything works fine but in BarChartView it's adding some default margin around the chart and I have done the below changes in the Chart property but still, it's not removing the margin around the graph.
I have also checked the same issue on this Question thread but no luck at all.
Check below screenshot for margin issue:
I have done the below changes for removing the margin around BarChart.
_barChartView.minOffset = 0;
_barChartView.xAxis.enabled = NO;
ChartYAxis *leftAxis = _barChartView.leftAxis;
leftAxis.drawGridLinesEnabled = NO;
_barChartView.leftAxis.enabled = NO;
_barChartView.leftAxis.drawAxisLineEnabled = NO;
_barChartView.rightAxis.enabled = NO;
_barChartView.rightAxis.drawAxisLineEnabled = NO;
_barChartView.legend.enabled = NO;
But still, I am not able to remove the margin.
Also checked Charts Demo app has the same issue while changing data from the slider.
Check Below screenshot from Chart Demo App:
Any help or hint appreciated :)
Hello I have checked in the demo of Charts library which you have provided.
Where i have added below code and it's work, check the screenshot below.
BarChartViewController.h
Add this code on line number : 115
_chartView.minOffset = 0;
_chartView.xAxis.enabled = NO;
_chartView.leftAxis.enabled = NO;
_chartView.leftAxis.drawAxisLineEnabled = NO;
_chartView.rightAxis.enabled = NO;
_chartView.rightAxis.drawAxisLineEnabled = NO;
_chartView.legend.enabled = NO;
let me know for more.
Here is the output of my simulator with blue background.
I know this is old but just for anyone who stumbles upon the question
This solved it for me
barChartView.leftAxis.axisMinimum = 0
barChartView.rightAxis.axisMinimum = 0
I tried to get a circle image using layer, here is my code
_compassArrow.layer.cornerRadius = _compassArrow.frame.size.width / 2;
_compassArrow.layer.masksToBounds = YES;
_compassArrow.layer.borderColor = [UIColor whiteColor].CGColor
the compassArrow is an imageview which display the compass image. And when I run my program, it looks terrible:
my actual picture
I don't know what happened to it. I've add some constraints to it, to make it has equal width with the device. Does this influence my image?
I think you set cornerRadius before your constraints are applied. Try to put this code in layoutSubviews or viewDidLayoutSubviews for example.
This way, the _compassArrow.frame.size.width value will be the one after constraints applied on it, and you'll get the correct cornerRadius.
Here is a piece of code that should allow you to do this.
_compassArrow.layer.borderWidth = 1.0
_compassArrow.layer.masksToBounds = false
_compassArrow.layer.borderColor = UIColor.whiteColor().CGColor
_compassArrow.layer.cornerRadius = profilePicture.frame.size.width/2
_compassArrow.clipsToBounds = true
I am new in cocos2d iPhone development.My question is how to use CCSlider in Cocos2d v3.2.
CCSlider has only two parameter (background spriteFrame and HandleImage).How we can change the colour/Image of slider when we change the Thumb position.How we can differentiate between empty and full bars, how to make progress of filling?
Suppose I want to use to colour like red(Empty) and green(Fill)/two different images for slider.By default the slider colour is red means the slider value is 0.0f(Empty).if I increase the value of slider then the slider colour will change to green(Fill) from position 0.0 to current thumb position.Please help me.sorry for my question i am very week in english
Thank You.
Here is how i use CCSlider for volume control. This code is in the init method of a GameOptions menu class:
CCSpriteFrame *frRuler = [CCSpriteFrame frameWithImageNamed:#"slider_track.png"];
CCSpriteFrame *frKnob = [CCSpriteFrame frameWithImageNamed:#"slider_knob.png"];
_mainGain = [[CCSlider alloc] initWithBackground:frRuler andHandleImage:frKnob];
[self addChild:_mainGain];
[_mainGain setTarget:self selector:#selector(onMainGainChange:)];
_mainGain.anchorPoint = ccp(.5, .5);
_mainGain.visible = YES;
_mainGain.positionType = CCPositionTypePoints;
_mainGain.position = ccp(kScreenWidth / 2, kScreenHeight / 2 - 55);
_mainGain.continuous = YES;
_mainGain.sliderValue = _battlesSettings.audio.masterVolumeGain; // initial
with the following method to receive the slider control 'slide' events :
- (void)onMainGainChange:(id)sender {
CCSlider *sl = (CCSlider *) sender;
_battlesSettings.audio.masterVolumeGain = sl.sliderValue;
_isSettingsDirty = YES;
}
I am creating a bar graph and then adding empty space above as follows....
CPTGraph *graph = self.hostView.hostedGraph;
graph.plotAreaFrame.paddingTop = smallPlotTopOffset; //some number like 25.0
I have already added paddingTop to the graph itself, and then used titleDisplacement to move the graph.title into this space.
However, now I would like to add a label between the title and the graph, in the space created by the plotAreaFrame.paddingTop. Is this possible using CPTTextLayers? I've been trying to add a layer, but they seem constrained by the plotAreaFrame (i.e. within the padding). I would like to align my label centred below my graph.title hence trying to use the hostView, rather than just adding a UILabel to the superview.
For anyone else interested I did this as follows....
CPTLayerAnnotation *ann = [[CPTLayerAnnotation alloc] initWithAnchorLayer:self.hostView.hostedGraph.plotAreaFrame];
ann.rectAnchor = CPTRectAnchorTop; //to make it the top centre of the plotFrame
ann.displacement = CGPointMake(0, -20.0); //To move it down, below the title
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:#"Your Text" style:nil];
ann.contentLayer = textLayer;
[self.hostView.hostedGraph.plotAreaFrame addAnnotation:ann];
I think this is the best way, although it'd be better if I could anchor it to below the main title, rather than add a manual displacement.
Use a layer annotation and add it to the graph.