View within a view - via FlipsideViewController


#1

I’m currently evaluating ShinobiCharts and am trying to create a small graph within another view (in this case the FlipsideViewController). I want the graph to only take up about 1/3 of the top of the view. I realize this must be trivial to do, but I can’t find how. All the examples use the chart as the main view controller, and searching the documentation hasn’t provided me with an answer. I’m a bit of a newcomer to Objective C so sorry if there is an obvious answer - it has so far eluded me.

Also, is it possible to plot functions i.e not just discrete point datasets?

P.S. your trial keys are the longest examples of keys I’ve ever seen :wink:


#2

Hi,

This is more of an objective C question that a ShinobiCharts question as ShinobiCharts is a subclass of UIView, and will lay itself out in the CGRect you provide for its frame. If you want to have your chart to be at the top of your view, and take up 1/3 of the screen (vertically?) then I would do the following:

ShinobiChart *myChart = [[ShinobiChart alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height/3)];

Or if your chart is already initialised:

myChart.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height/3);

As for plotting functions, this isn’t currently possible directly. If you wanted to plot a function you would need to calculate the points in the fuction yourself and then plot them on your chart!

I am glad you like our trial keys , you could always put it in a property list if it gets a bit annoying bang in the middle of your code  :smile:.

Jan


#3

Thanks so much Jan!


#4

One more trivial question: is there functionality to choose not to display axis numbers i.e. to create a graph with no visible axis identifiers at all? You can turn off the axis labels, but I can’t find the option to not draw axis units. It would be useful quite often I would imagine, and I’d like to offer it as a suggestion (if it does in fact not exist currently).


#5

Hi t0lkien,

You can hide an axis by setting the “showLabels” and “showTicks” properties on your axes “style.majorTickStyle” object. The following code hides a charts X-Axis:

yourChart.xAxis.style.majorTickStyle.showLabels = NO;
yourChart.xAxis.style.majorTickStyle.showTicks = NO;

Kind Regards,
Andrew Polkinghorn


#6

Thanks MrAPolk, that worked fine.


#7

Another question… I can’t reduce the size of the legend. It’s currently taking up half the view, and the symbol width can be reduced, but not the height (as a result it draws below the visible area and squeezes the chart off to the left). None of the chart.legend.placement or chart.legend.style.textAlignment stuff isn’t having any effect at all. Any ideas?


#8

Another question… I can’t reduce the size of the legend. It’s currently taking up half the view, and the symbol width can be reduced, but not the height (as a result it draws below the visible area and pushes the chart to the left). None of the chart.legend.placement or chart.legend.style.textAlignment stuff is having any effect at all i.e. they don’t change the legend size or placement. 

What I want is to squeeze both the size of the symbols (in my case colour blocks) and the associated labels down to quite small, and push the legend over the right so that it only takes up maybe 1/4 of the view area at most. The view area itself is already small - less than 1/3 of the iPhone screen - so I need it to be small, but neat.


#9

Hi t0lkien,

Just a quick note before we get started. In future, would it be possible for you to make new forum posts for each of your questions as it gives the opportunity for others in the forum community to easily find and view your question’s answer. Now back to answering your question.

You can customise your legend’s frame and the frames of each symbol within it as you would a normal UIView. This can be done in the SChartDelegate method “-sChartRenderFinished:”.

To access your legend’s frame you can use the “chart.legend.frame” property. To access each symbol you can loop through the symbols array which can be found on the legend’s “legend.symbols” property and change their frame.

However, when you change the legend’s frame, it is removed from the chart’s flow layout and the chart will fill the full frame you gave it. So make sure you take this into account when positioning your legend.

You can also reduce the size of the text on your legend via the “style.font” property on your legend. 

Kind Regards,
Andrew Polkinghorn