Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get scalable fonts when printing a scattergraph

Pete,

 

I've been messing with this and trying to get it to work and I haven't been successful yet.  What I've found is that you should create a new bitmap file, create the graphics object from that bitmap, then write to the graphics object, rather than writing to the graphics object presented by the printeventargs.  However, since this is what you are doing, I'm not sure what you are doing wrong.  I tried saving the bitmap after drawing to it, but that provided a GDI+ "generic error".

 

If I do find a solution, I'll let you know, but since this is more of a .NET issue, the people at the MSDN forums may be of more help (C# forums here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/threads/)

 

If anyone else has suggestions, feel free to post them.

Eric B.
National Instruments
0 Kudos
Message 11 of 14
(2,400 Views)

Hey Eric,

 

Well I got everything to print with the code below.  My issue now is with the resolution of the x and y axes and this is a Measurement Studio issue, I believe.  I set the resolution of my bitmap to 600 dpi (which is also the dpi of the PrintPageEventArgs found in the printing example) and the scatterplot happily adjusts but the axes expand in size even though I set the bounds to match to scattergraph's dimensions. any thoughts?

 

Bitmap _scatterGraphBmp;

private void GraphToBitmap()
{
            _scatterGraphBmp = new Bitmap(1,1, PixelFormat.Format32bppArgb);
            _scatterGraphBmp.SetResolution(600, 600);

            Graphics gBmp = Graphics.FromImage(_scatterGraphBmp);
           
            gBmp.Dispose();
            _scatterGraphBmp.Dispose();

            _scatterGraphBmp = new Bitmap(900,650, PixelFormat.Format32bppArgb);
            _scatterGraphBmp.SetResolution(600, 600);
            gBmp = Graphics.FromImage(_scatterGraphBmp);

            Rectangle yBounds = yAxis1.GetBounds();
            Rectangle xBounds = xAxis1.GetBounds();
            Rectangle plotBounds = new Rectangle(yBounds.Width, xBounds.Height, 899 - yBounds.Width, 649 - xBounds.Height);
            // Draw Chart Elements
            yBounds = yAxis1.GetBounds(gBmp, plotBounds);
            xBounds = xAxis1.GetBounds(gBmp, plotBounds);
            xAxis1.Draw(new ComponentDrawArgs(gBmp, xBounds), XAxisPosition.Bottom);
            yAxis1.Draw(new ComponentDrawArgs(gBmp, yBounds), YAxisPosition.Left);
            scatterGraph1.DrawGridLines(new ComponentDrawArgs(gBmp, plotBounds));
            scatterPlot1.Draw(new ComponentDrawArgs(gBmp, plotBounds));
            gBmp.DrawRectangle(new Pen(Brushes.Black), plotBounds);
           
            gBmp.Dispose();

}

 

Thanks,

Pete

0 Kudos
Message 12 of 14
(2,382 Views)

Hey Pete,

 

What do you mean that the axes expand in size?  Can you post a picture?

 

Thanks!

Eric B.
National Instruments
0 Kudos
Message 13 of 14
(2,351 Views)
NI may hate this but I've given up on Scattergraphs as used by Measurement Studio for a while now. I use ZedGraph as scaling is easier, manipulation of line points makes more sense and I can add reference "cursors" at will. The widget can print itself and the plots look nice. This is a LGPL item. We are not selling the software but we are selling the data. You can sell this as part of the product as long as you copy and distribute the source with the derived work along with a copy of the license. NI should consider including it with Measurement Studio.
0 Kudos
Message 14 of 14
(2,306 Views)