T O P I C R E V I E W |
BarryRobertson |
Posted - 17 Aug 2012 : 11:09:18 I was looking at the MultiLines area of the 2D examples which shades an area of the graph. However, I am trying to utilize this in the ScrollApplication example of the RT example set. I cannot seem to figure out what I'm doing wrong (I never see anything, or it give me an overflow error). If I use the normalized coordinates for the rectangle, I can see the rectangle, but that's not what I need.
Help?
How would you shade a 10 second section (full height) in the ScrollApplication example? In what I ultimately need to do, I need the height to be 100% all the time (the y-axis and x-axis scales can change).
Thank you! :)
Here's what I was last trying...
private void AddRegion() { Color alphaColor = Color.FromArgb(127, 170, 100, 50); ChartAttribute attribRegion = new ChartAttribute(alphaColor, 1, DashStyle.Solid, alphaColor); attribRegion.SetFillFlag(true);
double starttime = pTransform1.ScaleStartX + 5000; // start 5 seconds into the timeline double tenSeconds = 10 * 1000;
GraphicsPath rectpath = new GraphicsPath(); Rectangle2D linearRegionRect = new Rectangle2D(0, 0, tenSeconds, 100); rectpath.AddRectangle(linearRegionRect.GetRectangleF());
ChartShape linearRegionShape = new ChartShape(pTransform1, rectpath, ChartObj.PHYS_POS, starttime, pTransform1.ScaleStartY, ChartObj.PHYS_POS, 0); linearRegionShape.SetChartObjAttributes(attribRegion); chartVu.AddChartObject(linearRegionShape);
} |
2 L A T E S T R E P L I E S (Newest First) |
BarryRobertson |
Posted - 17 Aug 2012 : 14:48:16 Thank you for the information and suggestion. |
quinncurtis |
Posted - 17 Aug 2012 : 12:16:19 Your code is correct. Unfortunately you can't place the ChartShape objects using PhysicalCoordinates in a time based coordinate system. Because the ChartShape objects are run through the .Net Graphics Transform function for scale, rotate and translate, and that routine (not ours) for reasons known only known to Microsoft, uses the float numeric type for calculations. But our TimeCoordinates scale requires the precision of the double numeric type. So the .Net Transform function truncates the calculations so much they are no longer useable in our TimeCoordinates. In your case the solution is simpler than using a ChartShape object. Instead, just use one of our SimpleBarPlot objects. It can display one or more rectangles exactly as you require. Because it is not run through the .Net Transform function, it maintains full double precision. See the replacement code below:
private void AddRegion()
{
Color alphaColor = Color.FromArgb(127, 170, 100, 50);
ChartAttribute attribRegion = new ChartAttribute(alphaColor, 1, DashStyle.Solid, alphaColor);
attribRegion.SetFillFlag(true);
double starttime = pTransform1.ScaleStartX + 5000; // start 5 seconds into the timeline
double tenSeconds = 10 * 1000;
double [] xx = {starttime};
double [] yy = {10};
SimpleDataset Dataset1 = new SimpleDataset("One Bar", xx, yy);
ChartAttribute attrib1 = new ChartAttribute(alphaColor, 0, DashStyle.Solid, alphaColor);
SimpleBarPlot thePlot1 = new SimpleBarPlot(pTransform1, Dataset1, tenSeconds, pTransform1.ScaleStartY,
attrib1, ChartObj.JUSTIFY_MIN);
this.AddChartObject(thePlot1);
}
|
|
|