Coder Social home page Coder Social logo

vasturiano / proportions-chart Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 174 KB

A one-dimensional proportional chart web component for visualizing categorical data

Home Page: https://vasturiano.github.io/proportions-chart/example/basic/

License: MIT License

HTML 6.67% JavaScript 82.31% CSS 11.01%
proportions chart data-visualization d3js categorical-data

proportions-chart's Introduction

Proportions Chart

NPM package Build Size NPM Downloads

An interactive one-dimensional proportions chart for representing categorical data.

Quick start

import ProportionsChart from 'proportions-chart';

or using a script tag

<script src="//unpkg.com/proportions-chart"></script>

then

const myChart = ProportionsChart();
myChart(<myDOMElement>)
    .data(<myData>);

API reference

Method Description Default
data([array]) Getter/setter for the chart data, as an array of series objects, each representing a chart segment. []
width([number]) Getter/setter for the chart width in px. <window width>
height([number]) Getter/setter for the chart height in px. <window height>
label([string or fn]) Getter/setter for a series object label accessor, used to display labels on the segments and their tooltips. name
size([string or fn]) Getter/setter for a series object size accessor, used to compute the length of the segments. value
color([string or fn]) Getter/setter for a series object color accessor, used to color the segments. grey
sort([fn]) Getter/setter for the compare method used to sort the series. A value of null (default) maintains the existing order found in the input data structure. This method receives two arguments representing two series objects and expects a numeric return value (-1, 0 or 1) indicating the order. For example, to order segments by size, use: (a, b) => b.size - a.size. <existing order>
showLabels([boolean]) Getter/setter for whether to show labels in the segments. Regardless of this setting, labels too large to fit within a segment's boundaries are automatically hidden. true
tooltipContent([fn]) Getter/setter for a series object tooltip content accessor function. Use this to specify extra content in each of the segment's tooltips in addition to the series name that's included by default. <value (%)>
onClick([fn]) Callback function for click events. Includes the series object as single argument.
onHover([fn]) Callback function for mouse hover events. Includes the series object (or null if hovering outside the chart area) as single argument.

proportions-chart's People

Contributors

vasturiano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ksachikonye

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.