Generating and Saving ZedGraph plots without showing on forms

前端 未结 2 1500
北恋
北恋 2021-02-20 17:31

Is it possible to plot data on to a ZedGraph graph and save it as a file without showing / generating a graph that is visible to the user? I\'m looking to process a lot of datas

2条回答
  •  不知归路
    2021-02-20 18:20

    Here is a code snippet to create and save the Bitmaps without any WinForms infrastructure necessary:

    var zedGraph = new ZedGraphControl();
    
    // configure ZedGraphControl here
    
    using (var g = zedGraph.CreateGraphics())
    {
        zedGraph.MasterPane.ReSize(g, new RectangleF(0, 0, widthPx, heightPx));
    }
    zedGraph.MasterPane.GetImage().Save(Path.Combine(destinationDir, "test.bmp"));
    

    This should even be able to run as service without any desktop. The only downside is that you need to reference System.Windows.Forms and System.Drawing to use it.

提交回复
热议问题