question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display all points (circles) by default

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here

Expected behavior

It seems that in you can not display all the points by default in line and area chart other than putting all the data in the activeEntries, but once you hover the chart you lose all of the points again. Maybe I’m missing something but I can not find it in the documentation or elsewhere.

What is the motivation / use case for changing the behavior?

Sometime it is useful to have all the points (circles) displayed all the time because it is hard to determine where are the points in some cases.

  • ngx-charts version: 5.3.1
  • Angular version: 4.2.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:28 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
UmutAkkayacommented, Dec 5, 2018

I don’t understand why this issue is closed. I understand it might cause performance issues but it should be customizable and off by default.

7reactions
HDaghashcommented, Jul 1, 2020

if anyone still needs this feature I workaround this feature with a non-super clean solution but it works with no side effect so far : Screen Shot 2020-06-18 at 10 00 50 AM

custom service to draw the points over liner chart:

import { Injectable } from '@angular/core';
@Injectable()
export class CustomLinerChartService {
	/**
	 * custom: override SVG to have the dots display all the time over the liner chart
	 * since it's not supported anymore from ngx chart
	 */

	showDots(chart) {
		let index = 0;
		const paths = chart.chartElement.nativeElement.getElementsByClassName(
			'line-series'
		);
		const color = chart.chartElement.nativeElement.getElementsByClassName(
			'line-highlight'
		);

		for (let path of paths) {
			const chrtColor = color[index].getAttribute('ng-reflect-fill');
			const pathElement = path.getElementsByTagName('path')[0];
			const pathAttributes = {
				'marker-start': `url(#dot${index})`,
				'marker-mid': `url(#dot${index})`,
				'marker-end': `url(#dot${index})`
			};
			this.createMarker(chart, chrtColor, index);
			this.setAttributes(pathElement, pathAttributes);
			index += 1;
		}
	}

	/**
	 * create marker
	 *
	 */

	createMarker(chart, color, index) {
		const svg = chart.chartElement.nativeElement.getElementsByTagName('svg');
		var marker = document.createElementNS(
			'http://www.w3.org/2000/svg',
			'marker'
		);
		var circle = document.createElementNS(
			'http://www.w3.org/2000/svg',
			'circle'
		);
		svg[0].getElementsByTagName('defs')[0].append(marker);
		marker.append(circle);
		const m = svg[0].getElementsByTagName('marker')[0];
		const c = svg[0].getElementsByTagName('circle')[0];

		const markerAttributes = {
			id: `dot${index}`,
			viewBox: '0 0 10 10',
			refX: 5,
			refY: 5,
			markerWidth: 5,
			markerHeight: 5
		};

		const circleAttributes = {
			cx: 5,
			cy: 5,
			r: 5,
			fill: color
		};
		m.append(circle);

		this.setAttributes(m, markerAttributes);
		this.setAttributes(c, circleAttributes);
	}

	/**
	 * set multiple attributes
	 */
	setAttributes(element, attributes) {
		for (const key in attributes) {
			element.setAttribute(key, attributes[key]);
		}
	}
}

and after your view init and the data is set to the chart call :

	@ViewChild('chart') chart: any;

	ngAfterViewInit() {
		this.customLinerChartService.showDots(this.chart);
	}

make sure to have the reference on your chart : <ngx-charts-line-chart #chart>

UPDATE :

by mistake, I’m using ng-reflect-fill CSS class which will not be available on production mode so currently, I’m setting the color by index

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python all points on circle given radius and center
I would like to extract all the points with integer resolution present in the circle. Right now, I realised I am creating an...
Read more >
How to check if points lie within a circle
Is there a way to either check whether the circles overlap anyway, or to force the axes to share the same length? graphics...
Read more >
Marks — Altair 4.2.0 documentation
circle. mark_circle(). A scatter plot with filled circles. ... Note that the default behavior is to display outliers as points, where an outlier...
Read more >
StdDraw - Introduction to Programming in Java
All geometric shapes (such as points, lines, and circles) are drawn using the current pen color. By default, it is black. You can...
Read more >
sf::CircleShape Class Reference - SFML
Set the number of points of the circle. More. ... Set the sub-rectangle of the texture that the shape will display. More.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found