Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net
 Real-Time Graphics Tools for .Net (VB and C#)
 Shading an time-span area of a graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BarryRobertson

USA
21 Posts

Posted - 17 Aug 2012 :  11:09:18  Show Profile  Reply with Quote
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);

}

quinncurtis

1586 Posts

Posted - 17 Aug 2012 :  12:16:19  Show Profile  Reply with Quote
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);


        }


Go to Top of Page

BarryRobertson

USA
21 Posts

Posted - 17 Aug 2012 :  14:48:16  Show Profile  Reply with Quote
Thank you for the information and suggestion.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07