简体   繁体   中英

Scattered plot in ng2-charts

I have gone through the documentation of ng2-charts ( https://valor-software.com/ng2-charts/ ) but I couldn't find Scattered Plot in documentation. Is any other way to achieve Scattered plot chart in ng2-charts ? Any tricks or customization available? Help me out.

You could use a line chart in ng2-charts and set the color property as follows:

<canvas baseChart
   [colors]="chartColors"
   ...>
</canvas>

If you define chartColors like this:

public chartColors = [{
    backgroundColor: 'transparent',
    borderColor: 'transparent',
    pointBackgroundColor: '#ff0000',
    pointHoverBackgroundColor: '#fff',
    pointHoverBorderColor: '#ff0000'
  }];

You will get a transparent background (fill area under the chart) and a transparent line (the points will still be visible - making it appear as a scatter graph). The resulting graph should look something like this:

在此处输入图片说明

Please see this StackBlitz for a demo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM