How to draw a histogram chart in cocoa - cocoa

As per My requirements i need to generate a histogram chart using cocoa framework and objective c.
If any one knows the solution please let me know ASAP.
Thanks,
Ravi

You could use Core Plot. It doesn't support histograms directly, but if you calculate the bins and counts yourself, a bar plot is pretty easy to set up. The framework handles drawing everything including the axes and labels. It works on Mac, iPhone, and iPad.

Depending on your needs you can use a custom UIView subclass and perform the drawing by hand (overwrite drawRect:) or add UIViews for every bar (making nice animations possible with few code, but will not be efficient if many bars are needed).

You can easily write your own CALayer using CoreAnimation.
You will just need some basic CALayers with their colors, borders and shadows to draw the bars and some CATextLayers to draw the text on the axis or below bars.
With some basic CA knowledge it will be easy and allow you to easily customize the graph with animations or effects..

I know this question is pretty old but i found a link that gives sample code for drawing histogram
http://www.keepedge.com/iphone_charts/histogram_chart.html

You can look at DSBarChart. It does exactly what you want.
http://www.cocoacontrols.com/platforms/ios/controls/dsbarchart

Related

Building custom Shapes in Konva

I've been asked to build something similar to this so that customers can draw basics shapes of kitchen tops. Similar to that in the image below but also have dimensions.
It looks like konva has support for basic shapes like rectangle and circle etc and it also includes a transformer which allows for resizing. However, I think if I want to build a custom shape like the one in green and have individual sizing i.e. resize each individual line. I am going to have to build something myself.
I was hoping someone could point me in the right direction. I have seen an example where someone has used a "line" class which takes a series of points and then sets the attribute to closed which fills in the shape. Obviously I would need to extend this to allow the custom resizing. However, Im not sure this is the correct path to head down?
Any suggestions?
.
How about using rectangles and having an option to snap them together. It should be fairly simple to do the edge detection and snapping. Then show the result as a Konva.Line around the perimeter.
Then you can show all the control handles for the rectangles except those on the sides where another Rect has joined.

Scatter plot point shape

Is it possible to change the scatter plot point from the usual circle to something else. And more specifically can this be linked to a Dimension?
I know I can change the colour but we are already using a Master Item colour, and need to and another dimension.
We are also using the marker size for a measure so we cant co-opt that either
We are using Qlik Sense (SaaS).
From experience, no, you can't, I have ended up creating my own extension to create my own scatter plots to have donuts instead of dots using chart.js
Thanks,

Animate Sprite using color in top to bottom effect

How to spread color Top to Bottom using CCTintTo method in sprite.
Because i am using CCTintTo method to spread color in sprite. But i want to look like spreading color in top to bottom.
What to do for this types of animation.
Thanks in advance.
If you are using cocos2d 2.0+, you could write a shader to do this, and set the shaderProgram property of the sprite. Not that hard, follow the examples in the distribution. My first shader took me .5 work days to get to work, and maybe another .5 workday to properly integrate that technique properly in my overall software architecture. g'luck :).
Look here for an introduction to shaders, play with it in a side project until you are comfortable to integrate in your main trunk.
That's not possible with color tinting. Changing a node's color property or using the tint actions will only tint the entire sprite with a single color, there will be no gradient.
You would have to custom draw the sprite and apply/adapt the gradient rendering code from CCLayerGradient.
Yes CCLayerGradient is what you are looking for.By the way what technique you are using for coloring.If you are using CGContextSetRGBFillColor method to fill the sprite color then it would be tricky but if you are using images to fill color then nice sequence of images plist can be used to produce animation which will give you the exact effect you are looking for.
Take the sequence of images and animate them using CCSpriteBatchNode otherwise if you want to use RGB colors to fill sprite then you have to look for gradient effect.

OpenGL draw partial object in scrollable panel

I am making a GUI in OpenGL (more specifically lwjgl). I have tried hard to research different ways of doing this but I am having a hard time finding exactly what I want. I do not want to use any external libraries (only ones built in OpenGL, even trying to stay away from using GLUT) and I would like to have it work on anything that supports OpenGL (ex. Frame Buffer Objects don't work on older graphic cards).
I am making a 3D GUI with a scrollable panel as a component. The problem is I don't know how to draw a partial GUI component without doing a lot of calculations to only render part of it. I am making the components out of OpenGL primitives, not textures. I was hoping there is an easy way to do this like use multiple viewports. I don't really even understand what viewports are.
In short: I need to have a scrollable panel as a component overlapping other GUI components (since it will be a drop down menu) and not let any of the components in my panel draw outside my panel.
If you just want to prevent drawing pixels that are outside of a rectangular region (and I think that's what you're asking), than glScissor is exactly what you're looking for.
In lwjgl, you can find the function in org.lwjgl.opengl.GL11.
If you want to scroll a larger scene within a fixed region on the screen, the most straightforward way to go is by just modifying your projection matrix for the scroll position and redrawing the scene. If you are using gluPerspective to set up your projection matrix you'll have to convert it to a direct call to glFrustum; if you're using glOrtho it's much more straightforward.
Keep in mind that "scrolling" a perspective view has no one right way to do things - it depends on what sort of effect you want to achieve, and what particular sort of distortion you want near the edges of the overall viewport.

MATLAB GUI axes break window layout

I am developing a GUI frontend application in MATLAB. It's becoming quite complex these days, but as a showcase of the problem I'm having, I created a simple GUI containing an axes and a button. I display a surf(peaks) plot in the axes, and the buttonpress adds a colorbar('location','southoutside') to the plot. The axes stretch and overlap the boundaries I set for the object in GUIDE. Resizing them via set(handles.axes1,'Position',[...]) doesn't help. Any insights on how to compensate for this will be greatly appreciated.
As a side note, I'd like to add that maintaining an ever-growing application (especially a graphically-oriented one) in MATLAB is absolutely tedious if you want the widgets to do some more complex stuff. Great for creating something simple quickly, but don't get stuck building on that it if you can...
Apparently there's a property for the axes widget called OuterPosition which defines the extents of the axes containing all other objects surrounding the axes (labels, ticks, colorbar). Setting the ActivePositionProperty property to 'outerposition' causes the position to be preserved during scaling to be the outer position. Also, setting the Units property to 'normalized' allows for automatic scaling with respect to resizing the window. Oh joy. ;)

Resources