I am trying to display daily production data on a line chart in pounds of product produced per hour. We have 2 departments that appear on this chart however, some days 1 of the 2 departments may not be scheduled for production. On these days in my chart, I don't want to show a zero value for pounds per hour because it shows as a sharp dip in productivity. I need the line chart to skip that day for the zero value.Can anyone shed some light on how I can accomplish this?My datasource is a datatable with decimal values for the points on the line.Thanks in advance for your help,Trevor BraunThe Stirling Creamery Ltd.
this "GetIsolatedPoints" method should get you what you need, so in FillSceneGraph you can just use code like this:
Point[] isolatedPoints = this.GetIsolatedPoints(); foreach (Point isolatedPoint in isolatedPoints) { // draw an ellipse Ellipse plotPoint = new Ellipse(isolatedPoint, 4); plotPoint.PE.Fill = Color.Purple; plotPoint.Layer = this; // add the ellipse to the scene. scene.Add(plotPoint); }
private Point[] GetIsolatedPoints() { IAdvanceAxis xAxis = this.Grid["X"] as IAdvanceAxis; IAdvanceAxis yAxis = this.Grid["Y"] as IAdvanceAxis; int rowCount = this.ChartData.GetRowCount(); int colCount = this.ChartData.GetColumnCount(); List<Point> result = new List<Point>(); for (int r = 0; r < rowCount; r++) { int indexOfNonNullPoint = -1; bool isolated = true; for (int c = 0; c < colCount; c++) { object objectValue = this.ChartData.GetObjectValue(r, c); if (objectValue != null && !(objectValue is DBNull)) { if (indexOfNonNullPoint != -1) { isolated = false; break; } indexOfNonNullPoint = c; } } if (isolated) { object objectValue = this.ChartData.GetObjectValue(r, indexOfNonNullPoint); double dataValue = Convert.ToDouble(objectValue); int xPosition = Convert.ToInt32(xAxis.Map(indexOfNonNullPoint)); int yPosition = Convert.ToInt32(yAxis.Map(dataValue)); result.Add(new Point(xPosition, yPosition)); } } return result.ToArray(); }
allenovereem said:I don't have the e.ChartCore available in that implementation.
I assume you have implemented ILayer, in which case you can use this.ChartCore. ChartCore is a member of ILayer, and it will be set by the Chart so that use can use it in FillSceneGraph.
allenovereem said:Whatever values I cycle through are going to need to be accessed from my scene or by some other means of which I'm hoping you'll make me aware.
you can use this.ChartCore.GetChartLayer().ChartData or this.ChartData from your ILayer class. or, if you want to reference your data directly, just add a property to your ILayer class and store your data there.
ILayer
{
sourceData)
.MyData = sourceData;
}
_MyData;
;
} }
allenovereem said:Copying source code in doesn't work any better in IE than in Firefox. All formatting is lost.
well, I switched to IE and I see what you mean now. it works better if i paste from VS2008 to MSWord and then into IE.
internal class MyLayer : ILayer
public MyLayer(DataTable sourceData)
this.MyData = sourceData;
private DataTable _MyData;
internal DataTable MyData { get { return this._MyData; } set { this._MyData = value; } }
Here is the source code zipped. Let's see if that can be accessed...
Here is an image of the program output produced by the zipped source code...
There is a point in the source where I indicate I'll comment this out until I determine how to determine there is only one significant value for a particluar item... As you can see from that bit of code, I'm telling it to plot the ellipse based on the value of that point since I know what it is and since I've intentionally made sure there are no other points with that value.
If I could replace that with a piece of code that returns a boolean value (perhaps) indicating whether my item has one and only one significant point to plot then I could replace that if statement and be done. Unfortunately I'm not sure how to do that.
Other than that, I think all the issues with inaccurate line plotting using UltraChart is basically addressed by this code.
Trevor, I think this is the solution you were looking for with your original post BTW.
Thoughts? Suggestions for how this idiot (me) can identify whether a point is the only significant point for that item (like Purple in my example)?
Thanks,
Allen
As I've indicated, I'm using 7.1 and had to create a custom interface for FillSceneGraph.
I don't have the e.ChartCore available in that implementation.
Whatever values I cycle through are going to need to be accessed from my scene or by some other means of which I'm hoping you'll make me aware.
Copying source code in doesn't work any better in IE than in Firefox. All formatting is lost. I know there is something I'm missing because I see nicely formatted code all over this site.
Sure would make it easier if I could post some code along with my questions in order to qualify/elucidate what I'm asking.
allenovereem said:You didn't answer the question about how to post code nicely like you do. Is that not possible?
whoops. i just paste directly from visual studio into firefox, which doesn't really come out nicely. i think it works a lot better if you use IE.
allenovereem said:If I knew how to access the value for each day...
if you're using the Series collection as a datasource, it is easy, you can just loop through the DataPoints in each series.
if you're using the DataSource property of the chart, it's better to just go back to your data structure to find the isolated point.
if you can't do that for some reason, you can use the IChartData interface in FillSceneGraph...
IChartData chartData = e.ChartCore.GetChartLayer().ChartData;
// use chartData.GetRowCount(), GetColumnCount(), and GetValue(row, column) to iterate through your data.