This is an example of Angular Scatter Chart. The scatter chart is use to display values for two variables of a series through their coordinates. The values are represented as a collection of points. You can show more than two series by using different shapes for the values representation.
Loading...

Angular Chart: Scatter Chart

Angular Scatter Chart.

A live Angular example of jqxChart, the jQWidgets Chart component, with its complete source code below. It is one of 92 jqxChart demos for Angular.

jqxChart API used in this demo

Source code

To run it in your own app, install the package with npm install jqwidgets-ng, add these files to a standalone Angular CLI app, and add jqx.base.css and a theme to the styles in angular.json. Getting started with jqxChart shows the setup step by step.

app.ts

import { Component, viewChild } from '@angular/core';

import { jqxChartComponent } from 'jqwidgets-ng/jqxchart';
import { CommonModule } from '@angular/common';
import { jqxChartModule } from 'jqwidgets-ng/jqxchart';
import { jqxDropDownListModule } from 'jqwidgets-ng/jqxdropdownlist';

@Component({
    imports: [CommonModule, jqxChartModule, jqxDropDownListModule],
    selector: 'app-root',
    templateUrl: './app.html'
})

export class App {
    readonly myChart = viewChild.required<jqxChartComponent>('myChart');

    sampleData: any[] = [
        { City: 'New York', SalesQ1: 330500, SalesQ2: 210500, YoYGrowth: 1.05 },
        { City: 'London', SalesQ1: 120000, SalesQ2: 169000, YoYGrowth: 1.15 },
        { City: 'Paris', SalesQ1: 205000, SalesQ2: 275500, YoYGrowth: 1.45 },
        { City: 'Tokyo', SalesQ1: 187000, SalesQ2: 130100, YoYGrowth: 0.45 },
        { City: 'Berlin', SalesQ1: 187000, SalesQ2: 113000, YoYGrowth: 1.65 },
        { City: 'San Francisco', SalesQ1: 142000, SalesQ2: 102000, YoYGrowth: 1.25 },
        { City: 'Chicago', SalesQ1: 171000, SalesQ2: 124000, YoYGrowth: 0.75 }
    ];

    padding: any = { left: 5, top: 5, right: 5, bottom: 5 };

    titlePadding: any = { left: 90, top: 0, right: 0, bottom: 10 };

	getWidth() : any {
		if (document.body.offsetWidth < 850) {
			return '90%';
		}
		
		return 850;
	}
	
    xAxis: any =
    {
        dataField: 'City',
        valuesOnTicks: false
    };

    valueAxis: any =
    {
        minValue: 50000,
        maxValue: 350000,
        unitInterval: 50000,
        title: { text: 'Sales ($)<br>' },
        labels: {
            formatSettings: { prefix: '$', thousandsSeparator: ',' },
            horizontalAlignment: 'right'
        }
    };

    seriesGroups: any[] =
    [
        {
            type: 'scatter',
            series: [
                { dataField: 'SalesQ1', symbolSize: 20, symbolType: 'circle', displayText: 'Sales in Q1' },
                { dataField: 'SalesQ2', symbolSize: 20, symbolType: 'diamond', displayText: 'Sales in Q2' }
            ]
        }
    ];

    symbolsList: string[] = ['circle', 'diamond', 'square', 'triangle_up', 'triangle_down', 'triangle_left', 'triangle_right'];

    dropDownSerie1SymbolOnChange(event: any): void {
        let value = event.args.item.value;
        this.myChart().seriesGroups()[0].series[0].symbolType = value;
        this.myChart().update();
    }

    dropDownSerie2SymbolOnChange(event: any): void {
        let value = event.args.item.value;
        this.myChart().seriesGroups()[0].series[1].symbolType = value;
        this.myChart().update();
    }

}

app.html

<jqxChart #myChart
    [width]="getWidth()" [height]="500"
    [title]="'Sales by City in Q1 & Q2'"
    [description]="''"
    [showLegend]="true" [enableAnimations]="true" [padding]="padding"
    [titlePadding]="titlePadding" [source]="sampleData" [xAxis]="xAxis"
    [valueAxis]="valueAxis" [seriesGroups]="seriesGroups" [colorScheme]="'scheme01'">
</jqxChart>

<table style="width: 550px">
    <tbody>
        <tr>
            <td>
                <p>Select Serie 1 Symbol:</p>

                <jqxDropDownList (onChange)="dropDownSerie1SymbolOnChange($event)"
                    [width]="200" [height]="25" [selectedIndex]="2"
                    [dropDownHeight]="100" [source]="symbolsList">
                </jqxDropDownList>

            </td>
            <td>
                <p>Select Serie 2 Symbol:</p>

                <jqxDropDownList (onChange)="dropDownSerie2SymbolOnChange($event)"
                    [width]="200" [height]="25" [selectedIndex]="1"
                    [dropDownHeight]="100" [source]="symbolsList">
                </jqxDropDownList>

            </td>
        </tr>
    </tbody>
</table>

Learn more

More Angular Chart demos