I'm designing a Point and Figure Charting program, and my first version used the DataGridView control, which I found to be too big and bloated for my needs. All I need is a simple control that displays a square grid which will be filled with X's and O's.
The data is parsed from yahoo finance as Open, High, Low, Close data, sorted by a set of rules and converted to an Int Array, which will correspond with the index of the rows, so the simpler the control is, and the less bloat is has the more efficient it will be when chewing through large amounts of data.
I also need to be able to easily adjust the size of the squares in the grid, to zoom in and out of the data.
I am unfamiliar with creating custom controls (But willing to learn), and I'm not having a lot of luck with the search terms I'm using, so any help pointing in the right direction would be appreciated.
I've implemented a couple of custom controls like this before usually colour/graphics related stuff and they usually end up being more work than you imagine.
In the last project where I needed to do custom display stuff (a massive matrix of TCPConnection status between many different machines) I just used Xceed's gridControl and dynamically added the columns to the control. I kept an internal dictionary of the index of the column I added so that subsequent rows could benefit from direct reference to the column.
There are many different grid controls that you could probably utilise. Or if you want to get down and dirty with a Custom Control using the *Pain*t stuff you can do that too.
property for Columns, Rows .. Calculate the Space available then draw your Horiz/Verticals then draw you other values in the correct spaces, but eek prepare to invest quite a bit of time getting it "just right"
Related
I wanted to write an algorithm which could generate a 'maze' like structure within a closed room. [This is not a typical maze. I just want some walls here and there within the room.]
The catch is that I don't want any 'cycles'.
eg:
I want this:-
I do not want this:- [Here the bot is stuck as it cant access the rest of the room]
I understand this as not having cycles in the wall structure. So I thought of one solution: Generate a wall segment and then after generation check for cycles (if there are cycles, regenerate), but that seemed tedious as I'd have to encode stuff in a graph, so I thought of another solution.
Generate a wall segment and then choose an empty cell and see if you can reach all other empty cells from that cells (if not, regenerate). This one seemed promising but I did not know where to start.
Moreover these solutions don't address the elephant in the room: to generate the walls correctly in the first place! Moreover, one can't truly talk about the time complexity of the former algorithms.
How should I proceed with this problem?
P.S: I am using doing this in Unity with C#.
The recursive division maze generation method does what you want. https://en.wikipedia.org/wiki/Maze_generation_algorithm#Recursive_division_method
From the pictures you posted, you want wide open 'rooms', so you will want to stop the algorithm early. Instead of "until all chambers are minimum sized" you can specify required minimum size greated than 1.
Generate a wall segment and then choose an empty cell and see if you can reach all other empty cells from that cells
If you still wanted to use that idea, then one way to do that is to use a flood-fill algorithm to count the reachable tiles from the start location and confirm that it is the same as the number of empty tiles in total.
This page is part of a larger tutorial that contains a more detailed description of this idea. See the “Banishing disconnected islands (a roguelike developer's greatest enemy)” section.
Your problem is a little different than the standard "maze generation" algorithms, because you want to allow cycles in the path, just no cycles in the walls, and I think this is an important part of the game.
So, I would solve this using a variant of Kruskal's algorithm that satisfies this requirement.
Level 1
Initialize a disjoint set data structure. Make a set for every cell. Whenever we fill a cell with wall, we will merge its set with the sets of all adjacent filled cells (including diagonal neighbors).
Fill in all the border cells and merge their sets as indicated above.
Make a list of all the unfilled cells
Repeat the following until the list of unfilled cells is empty:
Choose an unfilled cell from the list at random.
Check the sets of its 8 neighbors. If any two of them are in the same set, then filling this cell would create a wall cycle. Discard it.
Otherwise, fill the cell, merging its set with its filled neighbors, and go back to step 4.
When you're done, you will have a pretty dense maze -- it will be impossible to fill any empty cell without creating a wall cycle. If you want a bit more space, you can remember and undo the last fills, or you can just stop filling after a certain number of cells are filled.
Level 2
Instead of using just one list of unfilled cells, divide them into buckets based on the pattern of their neighbors -- eight neighbors filled or unfilled makes 256 possible neighbor patterns.
Then, instead of choosing from the whole bunch randomly, assign different weights to each pattern and assign cells in that bucket a different probability.
This gives you a lot of power to adjust the character of the mazes you create until you find one that's right for you. Maybe you want avoid filling cells adjacent to walls, because that makes your maze too blocky. Maybe you want to prefer filling cells that continue the end of an existing path. Maybe you want to avoid filling cells that make diagonal connections. You can play with the weights you want until you get mazes you like.
I've done a similar thing with more traditional mazes here. Try adjusting the weights.
Note that this algorithm is very fast, with or without level 2. There is no backtracking/retrying, and operations on the disjoint set structure are effectively constant time, which makes the whole thing pretty much O(n)
I want to create a WPF a similar to the one in the image so that i can Bind the Image Source, The Movie Name & The Category (Ignore the left side)
Is this a ListView ? I tried many different combos but i couldn't make it as the one above.
Also, since it is related to that question, how i can have dynamically column number based on the Window size? For example in the image above the columns are 5, but i want it to be dynamically based on the Window Pixel/Size. Is this possible?
A lot of work to learn how to do it in a ListView. I'm not sure if the widths can be dynamic (based on each image width) but I've done it similarly to how Windows Explorer Icons views does it. So extra large, large, etc.
A good starting point for this is at https://msdn.microsoft.com/en-us/library/ms748859
But it's a tonne of work. Probably 2 or 3 months. They only give you bits and pieces and it's a variety of C# and VB.
You might want a more low-level ItemsControl.
Try the example from here: http://www.wpf-tutorial.com/list-controls/itemscontrol/
The one that might work for you is the WrapPanel as it will change the wrapping / layout based on the available container size and the item size.
Your Image and Text controls with bindings would go in the DataTemplate.
I have multiple series which share the same x-axis but some values are repeated as they have different number of data points. Since this is the case I want to set the same number of data points for all my series.
Is setting empty data points a solution to make all series have the same number of data points or are there any other solutions? If setting empty data points is a solution, how do I use it? My series aren't fixed and vary according to user selection.
They follow:
Chart1.Series[i].XValueMember = "Receipt date";
Chart1.Series[i].YValueMembers = "AvgAgingDays";
Is setting empty data points a solution?
Well, it certainly will achieve the counts to be the same. But how it looks is a different matter.
One question here is where do you inset them (X-Value), probably where they are missing, right?
The other question is what ChartType do your series have? Here are a few typical types:
Point, Bars, Columns: That is fine, just make the Color of the 'empty' Points Transparent!
Line, Area: That is more tricky. You don't want gaps in the lines so you need to keep them visible. And you want the lines to go straight so you need to calculate the Y-Values from the neighbours. Simple for one missing Point, a little bit more work for larger gaps. Not possible for points missing at the start or end. Those should be invisible again..
Spline: Next to impossible to get really right. Either put in some more work or live with some inaccuracies!
If you have a Line chart, to fully document the situation, you may consider adding a Point Series on top with the same data, but with the missing Points invisible.
Btw: If you have correctly set the XValueType as DateTime, all this ought to be unnecessary, as then the missing dates won't matter and the DataPoints all sit at their respective dates. They only shift if you don't have a valid X-Value and/or fitting XValueType.
This is a rather comon mistake because at first it all looks fine but without setting the type it will be string and then you run into trouble when you want to act on the values or rely on their positions or even just format them..
Btw: While it is possible to AddXY the missing points afterwards, it makes things a lot easier if you can detect and add them while adding the real points..
I have a WinForms application that allows you to edit documents. Each document is made of chapters and each chapter holds a collection of RTF blocks. The RTF blocks are loaded in a PanelControl using Dock = DockStyle.Top.
The problem is that when the total height of a chapter gets too large (estimating > 32768 pixels) the lower blocks are not properly docked: they appear behind one another. When trying to isolate the problem I noticed that this also happens with simpler controls like a LabelControl.
Things I tried are methods like Refresh(), Invalidate() and PerformLayout: they will not resolve the issue.
What does help is resizing the form. After that all controls are laid out correctly.
Can anyone help on how to solve this without resizing the form?
Attached a simple demo-project that illustrates the problem.
From my comment above (seems really to be the problem here):
WinForms (and the GDI in general) is often behaving unpredictably if one tries to use coordinates outside a 16 bit range. Try to avoid that. In the range of possible problems are things just not getting drawn at all, OverflowExceptions at unexpected code positions etc.
If it's possible to you take decision to change this layout, I suggest you to take another approach on showing/editing the documents chapters with some kind of pagination or collapsing RTF blocks into a menu and showing only current.
You see.. it makes a sense the height value be a integer 16-bit value.
A screen is way more tiny than this.
As panel height increases to such a high size. You see that using scroll bar will become very very sensible.. and it's not a good thing.
Content with size 2x, 3x, 5x being scrolled is usable to user. But scrolling a content with height (~32768) of at least (using good resolution monitor w/ window maximized) in optimal case 32x the size of window is very uncomfortable.
Plus, I believe that the productivity of user will decrease due to brain difficulty in locate "things" in a increasing collection of "things".
I would like to know if is there some good web solutions to show charts for "huge data sets", I've tried amcharts and Highcharts Stock (jquery solutions) without success.
At the beginning they were working, but at the moment the "chrome" is telling me that the javascript memory is full and the page crashes.
I've times where I need to show more than 20 lines, each one with more than 100.000 points, so in the end I can have gigantic jquery arrays that sure will crash the internet browser.
At the moment I am open to change to some flash, silverlight or other solution (not java applet because I am using C#).
What do you guys recommend?
UPDATE #1
For example: one purpose of this application is to see ECG channels.
The person will carry a device with several "sensors" (lets define 10 or 12, more or less), the device will save the data each second (or sometimes even in shorter intervals). And there can be cases that the person will use this system for 3 days).
Minimum data:
60 seconds * 60 minutes * 24 hours * 3 days = 259.200 points per line.
8 lines or more => 2.073.600 total points
Usability:
Well, in this health area normally the "readings" will be similar, no highs or lows enough to be recognized in a 3 days data. So for this example the best would be to load the data just when it is needed > the pan/zoom slide is showing just 1hour and when it moves to other, then AJAX get the rest of the DATA. Sure this is the way to go. BUT this is not the only case in my system.
I've other type or devices where the "highs and lows" are HUGE and the user would like to see ALL data in just one "chart" without zoom in. So, in this situations just from a simple look it is easy to see that something happened on the readings, then the user can make zoom in and since the data is already on memory no need to make more AJAX calls and refresh the chart.
Smart way to go: process the data in a way to do "reduce" the number of points when we are looking at a bigger "scale". Sure, this is the wise way to go, but once again, there are times when the result of some processing math will "fake" and hide the real readings and in the end there are some "behaviors" that will not show up on the chart.
So, for now I really need to find a way to display all of this points.
Note: I really appreciate all the feedback of you guys.
I think I'm with Neil here...there must be some way that this data can be processed before display...I mean, how can this amount of data even be displayed in a window? You say a line has 100000 points...if each of those points was unique in the X,Y plane, 100000 points would completely fill a 300x300 display window. 20 lines like this would completely saturate a normal 1024x1280 display.
Presumably, that can't be what you are looking for, so I'm assuming there must be a lot of cases where the points overlap. Preprocessing the data, to eliminate duplicate data points would help reduce the data size considerably.
It's hard to know exactly how this answer fits, or to give more precise instructions without further details, but if you have questions or clarifications, edit your question and I'll modify my answer (or delete it, if I've misinterpreted.)
Response to Edit 1:
I think that the way to approach the thinking for this is to recognize that for any given view, you can only show as many data points as you have horizontal resolution, so you can limit your data download to that.
From what I'm hearing (and I grant that I have very few details) this problem can be reduced to:
Figuring out how many points to get (based on horizontal resolution)
Calculating those points based on the data, horizontal scroll, zoom, and any heuristics.
Dynamically downloading that data
That sounds not too bad, and your original problem (of too much data crashing the system) disappears. That leaves you with secondary problem of how to calculate the height of the downloaded data.
I've other type or devices where the "highs and lows" are HUGE and the
user would like to see ALL data in just one "chart" without zoom in.
So, in this situations just from a simple look it is easy to see that
something happened on the readings...
There are a number of potential difficulties that I can see here...
If the timescale for these events is too short, they won't be visible on a naively drawn graph. If you have 100000 points in a particular line graph and your default viewing area is 1000 pixels wide with no zooming, you're only seeing 1 out of 100 datapoints. If some spike lasts for 10 of the datapoints, for example, unless you do something special, there's a good chance it won't be visible on the graph (so the user won't know to "zoom in" for more resolution). And how do you determine the height at which to plot the point? The actual datapoint at a specific spot? An average of the 100 data points that pixel covers? A rolling average? If don't average, you could miss spikes entirely. If you do average, you could lower the amplitude of the spikes or troughs if they are of short duration.
This, I think (and, again, I'm doing a lot of guesswork) sounds like the real challenge. Trying to find some way to display the graph which will definitely not be able to show all of the data at one time, but may be able to have some way to highlight points of interest dynamically (calculating, noting, and marking peaks and troughs with notations on the graph...things like that.)
Try out the Zoom Line chart from the FusionCharts stables.
I've myself created charts with 27,000 datapoints; and beyond the initial loading times, the chart worked smoothly.
Here is a blog post about the zoom line chart - http://blog.fusioncharts.com/2011/10/stuck-between-massive-historical-data-and-daily-intricacies-zoom-line-chart-to-the-rescue/
As a bonus, you can render the chart in pure JavaScript or Flash.
And it also works well with server-side languages. Check out their docs for more reading material - http://docs.fusioncharts.com/