Click or drag to resize

Draw a line graph

How to programming a line graph with SIC Draw module.

Using assembly SIC.Draw

This topic contains the following sections:

Project example easyPlan create a characteristic curve.

There are two possibilities implement SIC.Draw object. Implement SIC.Draw as a object or implement SIC.Draw as inherited to class.

This example implemented as a object because not need a refrence to SIC.Draw in the user interface (only in the logic layer).

SIC Draw assembly implementation

  1. Add Reference SIC.Draw in the project

  2. Create a class with line graph object

    C#
    /// <summary>
    /// Anlagekennlinie Chart
    /// </summary>
    /// <remarks>
    /// Using assembly reference: SIC.Draw
    /// </remarks>
    public class AnlagekennlinieChart
    {
        /// <summary>
        /// Constructor without parameter
        /// </summary>
        public AnlagekennlinieChart() { }
    
        /// <summary>
        /// Anlagekennlinie Grafik
        /// </summary>
        private SIC.Draw.LineChart Chart { get; set; }
    
    }

Is it finished? Then it can already a draw a graphic.

Create method that create a line chart graphic.

  • C#
    /// <summary>
    /// Create a new Anlagekennlinie chart.
    /// </summary>
    /// <remarks>
    /// Chart save as a JPEG image file.
    /// </remarks>
    /// <param name="pFileName">File name include path to store the chart</param>
    /// <param name="pAnlagekennlinie">Anlagekennlinie data object</param>
    public void Create(string pFileName, easyPlanData.Anlagekennlinie pAnlagekennlinie)
    
    {
        //* default values *
        int lWidth = 605;
        int lHeight = 495;
        int lBorderSpacing = 45;
        int lXLabelSpacing = 30;
        int lYLabelSpacing = 30;
        string lXLabel = "Q [l/s]";
        string lYLabel = "H [mWS]";
        bool lShowScaling = false;       //* test mode: true *
    
        //* save Anlagekennlinie values *
        this.Anlagekennlinie = pAnlagekennlinie;
    
        //* create Analgekennlinie line chart *
        if (pFileName == "")
        {
            throw new System.Exception("Anlagekennlinie Chart method Create: has no Filename (parameter)");
        }
    
        this.Chart = new SIC.Draw.LineChart();
        this.Chart.Create(pFileName, this.XAxis, this.YAxis, this.Points, SIC.Draw.LineChartType.Curve,
                          pWidth: lWidth, pHeight: lHeight,
                          pBorderSpacing: lBorderSpacing, pXLabelSpacing: lXLabelSpacing, pYLabelSpacing: lYLabelSpacing,
                          pShowScaling: lShowScaling,
                          pPoints2: this.Points2,
                          pXLabel: lXLabel,
                          pYLabel: lYLabel);
    
        //* store the saved file name *
        this.FileName = this.Chart.File;
    }
See Also