apexchartsng-apexcharts

apexcharts draw line chart on top of scatter chart


Currently using "Scatter Charts" to display my xy coordinates, working great. Another requirement is to draw a line chart based on average numbers on top of the scatter chart. Is this possible?

Link to Scatter Charts - https://apexcharts.com/angular-chart-demos/scatter-charts/basic/

Sample graph -enter image description here


Solution

  • This also works in Angular, here is a sample config:

    this.chartOptions = {          
                series: [{
                    name: "Points",
                    type: 'scatter',
                    data: [{x: 1, y: 3}, {x: 2, y: 4}]
                  },
                  {
                    name: "Line 1",
                    type: 'line',
                    data: [{x: 1, y: 1}, {x: 2, y: 2}]
                  },
                  {
                    name: "Line 2",
                    type: 'line',
                    data: [{x: 1, y: 5}, {x: 2, y: 7}]
                  }],
                markers: {
                    size:[5,0,0],
                },
                stroke:{
                    width:[0, 2, 3]
                },
                chart: {
                    type: 'line',
                }
    };
    
    

    And don't forget to add the config in the HTML or else it will not work:

    <apx-chart
            [series]="chartOptions.series"
            [chart]="chartOptions.chart"
            [markers]="chartOptions.markers"
            [stroke]="chartOptions.stroke"></apx-chart>