npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hinkage/pie3d_svg

v2.0.8

Published

3D pie chart supports variable heights of diffrent slices and inner radius with transition and auto rotating implemented by SVG.

Downloads

13

Readme

pie3d_svg

3D pie chart supports variable heights of diffrent slices and inner radius with transition and auto rotating implemented by SVG.

npm package

npm i @hinkage/pie3d_svg

Example

pie3d_svg.png

example video

example/test.js

let el = document.querySelector('.test');
let inst = Pie3D(el);
inst.render({
	data: fakeData(),
	colorArray: [
		'rgba(213, 63, 11, 1.0)',
		'rgba(89, 19, 208, 1.0)',
		'rgba(56, 140, 227, 1.0)',
		'rgba(20, 202, 156, 1.0)',
		'rgba(185, 195, 16, 1.0)',
		'rgba(210, 138, 26, 1.0)',
		'rgba(109, 175, 243, 1.0)',
		'rgba(108, 200, 243, 1.0)'
	],
	x: 300,
	y: 250,
	width: 150,
	height: 80,
	depth: 30,
	depthRange: [20, 60],
	innerRadius: 0.6,
	startAngle: 270,
	enableTransition: true,
	enableAutoRotate: true,
	rotateDuration: 1000,
	rotateInterval: 2000,
	onRotate: function (d, i) {
		console.log('onRotate:', d, i);
	}
});

Config

Look at src/default_config.js.

The default config will be overridden by the object passed to function render. Try to change the value of each property to see what will happend to understand what the property means.

Caution

startAngle can only be set to 270 degrees, because of the limitation of SVG. SVG is designed for 2D graphic, not for 3D graphic like this.

You can try to set startAngle to 0 degrees, then only provide two items of data, click on update button several times, then you can find the problem. No matter which order that two parts are placed, the overlapping result is wrong.

In 3D graphic, each single pixel's distance to camera must be calculated to decide we can see that pixel or not, this is not possible in SVG. This is the biggest limitation of this implementation. The perfect implemetation can only be done by WebGL, which is the real 3D graphic interface.

There is another library: amcharts variable-height-3d-pie-chart-v4.

As I test, It has the same problem as this repository, when the startAngle is set to 0, and endAngle is set 360, and only provide two items of data, it produces the same problem.