Is there any way an alignment can be provided for the title in Core Plot apart from setting the graph title displacement.I am having a dynamic graph title and hence the title displacement would also have to be adjusted accordingly for each case. Also is there a way to set the font Style of the title say make it Bold?
If the titlePlotAreaFrameAnchor and titleDisplacement don't give enough control, you can always use a Core Plot layer annotation to position your own custom title anywhere you want.
Core Plot text styles include several properties including the font, size, color, bold, and italics. If you want the whole title to use one style, just set the title string and the titleTextStyle. If you want parts of the title to have different styles, use the attributedTitle (which takes an NSAttributedString) instead. See some of the plots in the Plot Gallery example app for sample code.
Related
Can I put a UIButton or UITextField or UITextView between the texts in Swift
examples:
"What is your **[UITextField]** about downloading free music files from the Internet?**[UIButton]**"
"What is your
**[UITextField]** about
downloading free
music files from the
Internet?**[UIButton]**"
Like "example2", the layout may change depending on the situation.
Not a particularly easy task. You can use attributed text to stylize a word and make it "tappable" (like a hyperlink on a webpage), but that wouldn't solve the issue of embedding an editable text field in the string.
One approach would be to embed "placeholder" text in your string, then find the bounding box for that word and overlay a textfield or button. You'd have to be sure to account for things like word wrap, and it would take some experimentation to get the widths right.
So, you might set the text of your label to:
What is your UITextFieldGoesHere about downloading free music files from the Internet? UIButtonHere
Then use code to find the bounding box / rect of UITextFieldGoesHere and position a text field on top of that, so it covers the word and looks like it is inline. Same thing with the UIButtonHere.
If your button might be simply OK, and you don't want it wide with left-right padding, change that placeholder in your string to something like OKB ... just make sure it is unique so you can find it.
Lots of examples out there for finding the bounding box / rect of a word in a label... use Google (or your favorite search engine) to search for:
uilabel find bounding box of specific word
When creating a treemap structure with boxes, boxes with a text that is larger than the box itself are not drawn.
Below the same treemap is show twice: once with text, once without text.
treemap with text
image without text
How do I prevent this from happening?
I'm pretty sure this can't be prevented. The reason is that the box sizes have hard constraints on their sizes (the size is as meaningful as the height of a bar in a bar chart), so they can't grow with the size of the enclosed text.
To fix this you could generate shorter labels (removing all the vowls and truncating them) and showing the full label as a tooltip? Or you could have a box with a label in it on the side which contains the currently hovered box?
Hope you people doing great.I am new to Core Plot api and need your suggestion.I want to customize x index of plot and wants to add icon and label to each index.As I have searched , I got to make policy none to index but I want to add image to each label.Help will be much appreciated.
Custom axis labels don't have to be just text. The label's contentLayer can be any CPTLayer. Depending on what you're trying to achieve, you could render your text and label into an image and use that as the fill for a CPTBorderedLayer, add the icon (in a bordered layer) as a sublayer to the text layer for the label, or even create a custom CPTLayer subclass that draws everything the way you want it.
Is it possible to set a title instead of A CPTPlotSymbol ? I want to display the co-ordinates instead of a symbol.Here is the screen shot.I want a label where , there is a circle symbol plot in the screen shot.
Set the plotSymbol to nil to remove the symbols from the plot. You want to use data labels to label the points. If you just want to show the y-coordinate, set a labelTextStyle and labelFormatter. The plot will create and display labels automatically using the given style and number format.
If you need more complex labels (e.g., showing both x and y coordinates), you can make custom labels. Implement the -dataLabelForPlot:recordIndex: datasource method. This method can return any CPTLayer, so you have a lot of flexibility. For simple text labels, create a string with the label text and display it in a CPTTextLayer. The plot will position the label for you and keep it aligned with the data point if it moves.
I use a custom font in my Core Plot legend. However, this causes the label to no longer be vertically aligned with the plot key (the little color line representing the plot above). When using a standard font, the alignment is perfect. Can this be fixed please?