ZedGraph - How to fill the area between two curves? - c#

I've two curves. One of them is above the another. I've also set the IsSmooth to true (the lines are bent at the corners).
I want to fill the area between the top and bottom curveā€¦
What's the best method to do so?
I think using PolyObj is not a good idea because I have to store the points separately, and the final filled area is not smooth like the lines.
Here is a sample:

Related

AutoCAD .NET: Filling a Region with a grid / custom hatch

I want to fill a selected region with a custom hatch that looks like a grid (like a chess table). I tried to use the ANSI37 pattern but its lines are too dense and I could not modify anything visually except the angle of the hatch. Also, I tried the custom hatch pattern creation of autocad but loading the file in autocad or creating a hatch from it in my code always results in error.This is my question: Is there anyway I can create a custom hatch pattern (grid like) that I can control the distance of lines of the grid? Is it possible for me to retrieve the custom hatch object later then query info of its lines? (how many lines, start points and end points, distance between them...)
? Thank you in advance.
About customize the predefined hatch pattern: It is possible to do that, however the properties of the hatch must be defined in a certain order to have actual effect, or else it will be ignored and use the default value instead.
for example: in my case, I defined the value of HatchStyle before PatternScale and PatternSpace while it should be the other way around. Thus, I receive the result from the default values.
About the custom grid lines drawing and querying: I got some ideas from these:
http://adndevblog.typepad.com/autocad/2013/07/create-hatch-objects-using-trace-boundaries-using-net.html
using the Editor.TraceBoudary() method, I can retrieve the loops I needed with the outer most loop will be the last entry in the return DBObjectCollection (a Polyline object to be precise). Then, create the region that needed to be hatched and access its RegionAreaProperty.Extends to get the bottom-left and top-right point of the rectangle that contains my newly created region. After that
, I can implement my logic to draw the lines of the grid.
Note that this method only works on 2d loops ( regions, closed polylines, lines, curves... on Oxy plane). I haven't find a way for the Editor.TraceBoundary() to work with 3d loops yet.
Still open for advices and suggestion for 3d loops and creating custom hatch from a given HatchPattern object.

How to set the same number of data points in a Line Chart?

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..

Can you allocate space at the bottom of a .NET Chart Control

I'm using the .net chart control. I'd like to allocate some space at the bottom of the chart to add some additional information (date, associated file name, note, etc.) - about 0 to 4 lines in total. To do this I'd like to allocate some reserved space below the X axis title (the 0 to 4 lines worth) and use an annotation anchored to the bottom to contain the additional information. Or, if there's some other way to accomplish the same thing, that would be great.
I've been working for a couple of days trying to accomplish this but have not found a "professional" way to do it. I am able to do it by adding several blank lines to the X axis label, but I'd like something a little better than that.
I am using a dock style of fill and allowing auto sizing. I've tried margins and padding with no success. Annotations appear to simply overlay existing area on the chart but do not allocate any additional space.
I'm looking to allocate a fixed size block at the bottom since the text block will be a fixed size height, rather than a percentage (relative coordinates).
Does anyone have any suggestions that I might try? Thanks!
I found a way to accomplish what I was looking to do. I simply used a chart Title and docked it to the bottom of the chart. It allows me to add in the extra data that I wanted to add and space is properly allocated for it. I'm new to using MSCharts and hadn't noticed that I could use multiple titles docked to different places on the chart.

Removing black areas from a scanned image with C#

I have a bunch of images, that look like .
After processing, I want them to be like .
I know that I can easily make those black areas white using the Flood Fill algorithm. But first of all I need to make sure that the black area is not part of the text. How can I do that? Those areas are huge, comparing to letters. So maybe I can just find out the size of each black area, and make the areas which are bigger than n white?
That's all about machinevision.
You could write your own code for something like "Connected-Component-Labeling"
This is just one possible approach.
Therefore you could start at the top left corner and gather all pixel that have almost the same grey value. save the coordinates and fill this area if the array contains more pixel than a certain threshold.
But i think you ll have some probs with the black "line" in the middle.

VISIBLOX, WPF: Getting chart points to scroll horizontally?

I'm using the Visiblox WPF API and am having trouble getting the chart points in my line chart to scroll horizontally. Instead of scrolling, the points are get squashed together, in which, this isn't particularly a problem, except that I expect to have 100s of data points on the chart. I have looked throughout the examples available on the Visiblox website, but couldn't find what I was looking for. Ive attached an example screenshot.
Any ideas?
Thanks for your help,
Sparky
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches: 1) when you add the last point, remove the first one which will effectively move the visible window one point over or 2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified
I just had something like this recently. Everytime I'd add a point to the cart I'd run a little section of code that would check the amount of time (my x-axis dimension) that had passed since 0. I also set up a range of data I always wanted to see. I always wanted to show 120 seconds of data on the graph. So I had something like this:
private void adjustXasis(int timeCount)
{
if(timeCount>desiredRange)
{
chart.axis.Xaxis.minimum=timeCount-desiredRange;
chart.axis.Xaxis.maximum=timeCount;
}
else //two minutes not reached yet
{
chart.axis.Xaxis.minimum=0;
chart.axis.Xaxis.maximum=desiredRange;
}
}
I don't have VS in front of me and I know that syntax for the axis min/max is wrong but you get the idea.
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches:
1) when you add the last point, remove the first one which will effectively move the visible window one point over or
2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified

Categories

Resources