How to change the time frame in Xaxis of ZedGraph? - graphing

I need to have multiple time frame on a zedgraph. I have to display the stock data on a daily time frame and then if user wishes to view the view in monthly time frame or hourly time frame i need to support it. Note that the data must be in candle stick bar and not the line bar.
Currently i have 3 curves and i display only one at a time and hide the others. For example initially i set up my graph to be on daily time frame and hide the hour and monthly time frame candle stick curve. When the user gives the command to see the hourly graph i hide the daily candle stick and show the hourly time graph. However i am not able to change the x axis as it still shows the daily time instead of changing to hourly. I need to do something to change the x axis time frame from daily to hourly.
Any kind of help is appreciable. Please advise even if there is a workaround. Thanks.

You probably can do it by changing Min, Max and Step properties of XAxis.Scale object.
So, your method/event handler that supports this user action should:
- show/hide proper curves at pane, change
- adjust the scale using properties I listed above
- refresh the graph.
Note, that Refresh() method of ZedGraphControl isn't cheap. It redraws all elements on your graph, so if you have a lot of data, it isn't good idea to use it.
In that situation you should use combination of AxisChange() and Invalidate() methods. It should be faster and cheaper.

Related

How to resolve overlapping scatter points in a highchart

I have a time series data being plotted with Highstock API, as a scatter. When I am plotting it for a period of 5 days or more... my scatter points generated in very close proximity are getting totally overlapped. I have to close in my time frame to see that there are actually two points close by(which were overlapping).
so please help me on how i can improve display on this issue.
From what I've read and observed, this is one of the reasons to use a scatter plot: to see where data sets overlap, group together, and to show possible correlation (see the formal definition over at Wikipedia: https://en.wikipedia.org/wiki/Scatter_plot).
You may wish to add a note to the chart that encourages your users to zoom in to see more detail. The zoom function is a native part of Highcharts/Highstock, but isn't immediately obvious to many users.
It's worth noting that you can limit the zoom to either one axis (zoomType: 'x') or both axes (zoomType: 'xy'); see http://api.highcharts.com/highcharts#chart.zoomType. That may offer you a bit more control over how you want your users to view the parts of the chart with a larger number of overlapping points.

Dynamic scaling for tick intervals in Core Plot

I have a graph showing dates on 1 day intervals on the X-axis. This works fine, however, the tick labels tend to overlap each other and make it look like a mess.
By default, the major tick interval is set to one day. I would like it to scale with the rest of the graph, i.e. when I scale back enough, the major tick interval would be set to one week, one month, etc.
How would I go on implementing this one?
There's no way yet to do this automatically. The best solution would be to use a plot space delegate to monitor changes to the plot space range and adjust the labeling as needed based on the current range.

How may I get a DataVisualization.Charting Chart to render only the added points, for fast refresh?

How may I get a Line-style DataVisualization.Charting.Chart holding many points to render only the points that have been added since the last render, in order to decrease the refresh time?
I have a real-time line Chart showing a plot of measurement values Yn against time X. On adding the first few points rendering is effectively instant, but on adding the thousandth point it is unacceptably slow (~0.5s on this 3.5GHz P4). I need fast refresh on up to 10,000 points. FastLine style is about 10x faster than Line style, but the charts requirement for markers makes this not an option.
Thanks.

How do I calculate fps in a simple Direct2D app?

Hey guys, and thanks for looking. I have built the simple D2D app from MSDN, available here. Now, I want to draw some primitives and add an fps counter.
I have an OnRender() event, where I draw the rectangles and so on. I also have a call to RenderTextInfo() where I call RenderTarget->DrawText. Where do I add the logic for counting the number of frames per second?
Thanks much.
I don't know the exact Direct2D stuff, but this might help.
Basically, you have two choices. Either you update the framerate when you draw a frame, or each second (or any other time interval).
If you count it when you draw a frame, you can simply get the current time when you draw a frame, and subtract from it the time you drew the last frame. That gets you the time spent drawing this frame. The reciprocal of that (i.e. 1/x) is the framerate.
If you count it at a regular time interval, you need to have some event firing at every interval that checks how many frames were drawn since the last time that event fired. Divide that by your interval (if it's one second, you don't need to divide, of course) and that's your fps count. Don't forget to increment some counter every time you draw a frame.

How to set/corrent the resting position of UIScrollView contents after it has scrolled

I am implementing a view similar to a Table View which contains rows of data. What I am trying to do is that after scrolling, each row snaps to a set of correct positions so the boundaries of the top and bottom row are completely visible - and not trimmed as it normally happens. Is there a way to get the scroll destination before the scrolling starts? This way I will be able to correct the final y-position, for example, in multiples of row height.
I asked the same question a couple of weeks ago.
There is definitely no public API to determine the final resting Y offset of a scroll deceleration. After researching it further, I wasn't able to figure out Apple's formula for how they manage deceleration. I gathered a bunch of data from scrolling events, recording the beginning velocity and how far the deceleration traveled, and from that made some rough estimates of where it was likely to stop.
My goal was to predict well in advance where it would stop, and to convert the deceleration into a specific move to an offset. The problem with this technique is that scrollRectToVisible:animated: always occurs over a set period of time, so instead of the velocity the user expects from a flick gesture, it's either much faster or much slower, depending on the strength of the flick.
Another choice is to observe the deceleration and wait until it slows down to some threshold, then call scrollRectToVisible:animated:, but even this is difficult to get "just right."
A third choice is to wait until the deceleration completes on its own, check to see if it happened to stop at your desired offset multiple, and then adjust if not. I don't care for this personally, as you either coast to a stop and then speed up or coast to a stop and reverse direction.