Documents for Excel .NET Edition | GCDocuments
Features / Chart / Chart Types / XY (Scatter) Chart
In This Topic
    XY (Scatter) Chart
    In This Topic

    Scatter chart is used to illustrate relationships between individual items or categories. This chart is ideal for showing comparisons for scientific, statistical and engineering data. The data arranged in columns or rows of a worksheet can be plotted in a Scatter chart.

    Unlike other charts, a scatter chart displays the actual values of the x and y variables in horizontal axis and vertical axis in the plot area. Typically, this chart combines the x and y values into single data points and displays them at irregular intervals. Also, this chart does not make use of the category axis because both horizontal axis (primary axis) and vertical axes (secondary axis) are value axes.

    GcExcel supports the following types of Scatter charts.

    Chart Type Chart Snapshot Use Case
    XYScatter
    XYScatter chart

    XYScatter chart

    A clustered Scatter chart displays the data points based on a selected data range. This helps the users to analyze and determine the relationship between x and y variables.
    XYScatterLines
    XYScatterLines chart

    XYScatterLines chart

    A scatter chart with straight lines displays a straight connecting line between data points in a particular series without showing the individual points.
    XYScatterLinesNoMarkers
    XYScatterLinesNoMarkers chart

    XYScatterLinesNoMarkers chart

    A scatter chart with straight lines and no data markers displays a smooth curve that connects all the data points in a particular series.
    XYScatterSmooth
    XYScatterSmooth chart

    XYScatterSmooth chart

    A scatter chart with smooth lines displays a connecting line between data points in a particular series without showing the individual points.
    XYScatterSmoothNoMarkers
    XYScatterSmoothNoMarkers chart

    XYScatterSmoothNoMarkers chart

    A scatter chart with smooth lines and no data markers displays a smooth curve that connects all the data points in a particular series.
    Bubble
    Bubble chart

    Bubble chart

    A bubble chart is ideal for financial data analysis. It displays the variations of a scatter chart where data points are replaced with bubbles and a third dimension is represented (Z axis) in the size of the bubbles. This chart plots z(size) values as well as x values and y values. Typically, this chart can be used when you want to plot three data series. The size of the bubbles is determined by the values in the third data series.
    Bubble3DEffect
    Bubble3DEffect chart

    Bubble3DEffect chart

    Bubble3DEffect chart can be used to display the chart demonstration in 3D,which is a modification of 2DBubble chart. It does not have a third dimension, it only looks volumetric in appearance.

    Using Code

    Refer to the following code to add a XY Scatter chart:

    C#
    Copy Code
    public void ScatterCharts()
    {
        // Initialize workbook
        Workbook workbook = new Workbook();
        // Fetch default worksheet 
        IWorksheet worksheet = workbook.Worksheets[0];
    
        // Prepare data for chart
        worksheet.Range["A1:C22"].Value = new object[,] {
      { "Index", "Zantedeschia", "Celosia" },
      { 0, 0, 0 }, {1, 30, 10 }, {2, 50, 21 }, {3, 90, 35 },
      {4, 67, 7 }, {5, 59, 24 }, {6, 28, 6 }, {7, 78, 50 },
      {8, 90, 20 }, {9, 100, 40 }, {10, 45, 6 }, {11, 87, 20 },
      {12, 21, 5 }, {13, 45, 25 }, {14, 68, 63 }, {15, 98, 40 },
      {16, 23, 6 }, {17, 89, 20 }, {18, 13, 6 }, {19, 90, 9 }, {20, 100, 80 }
      };
        worksheet.Range["A:C"].Columns.AutoFit();
        // Add XYScatter Chart
        IShape xyScatterChartshape = worksheet.Shapes.AddChart(ChartType.XYScatter, 250, 20, 360, 230);
    
        // Adding series to SeriesCollection
        xyScatterChartshape.Chart.SeriesCollection.Add(worksheet.Range["B1:B22"], RowCol.Columns);
        xyScatterChartshape.Chart.SeriesCollection.Add(worksheet.Range["C1:C22"], RowCol.Columns);
      
    
        // Configure Chart Title 
        xyScatterChartshape.Chart.ChartTitle.Text = "The Influence of Greenhouse Cultivation on Different Flowers";
    
        // Configure Markers style
        ISeries series1 = xyScatterChartshape.Chart.SeriesCollection[0];
        series1.MarkerStyle = MarkerStyle.Diamond;
        series1.MarkerSize = 7;
        ISeries series2 = xyScatterChartshape.Chart.SeriesCollection[1];
        series2.MarkerStyle = MarkerStyle.Star;
        series2.MarkerSize = 7;
    
        // Saving workbook to Xlsx
        workbook.Save(@"26-ScatterChart.xlsx", SaveFileFormat.Xlsx);
    }