GithubHelp home page GithubHelp logo

scrollablechart's Introduction

ScrollableChart

Plugin for Chart.js that allows you create a scrollable Bar/Line chart.

This is a very simple plugin written in jQuery and is available under the [MIT license].

Basic Usage

Setup HTML for a chart (refer to Chart.js documentation for more details: http://www.chartjs.org/docs/ )

*you must add a next and previous button somewhere that will connect to the chart.

NOTE: the next and previous buttons must have a data-shift attribute denoting whether it is "next" or "prev"

Ex.

<div data-shift="prev">
	<span>Left</span>
</div>
<div>
	<canvas id="canvas"></canvas>
</div>
<div data-shift="next">
	<span>Right</span>
</div>

Once you have the basic HTML setup initialization is pretty simple.

You need to pass an object to the plugin with the following possible values:

Parameter Description
data an array of data for the chart, this is the dataset data passed to Chart.js
labels an array of equal length to the data to label the data
nextButton string/DOM object of the next button
prevButton string/DOM object of the previous button
indexDisplay optional string/DOM object where you want to display the first and last labels currently being shown
maxshown # of bars/points to show on one "page" of the chart (defaults to 1 if not set)
chartType a string indicating whether the chart should be a Bar or Line chart

Initialization

$(mycanvas).scrollingChart({
	data: [1,2,6,7,2,5,4,9,36,5,4,3,6],
	labels: ['Bacon','ipsum','dolor','amet','salami','pastrami','pancetta','cow','strip','steak','porchetta','kielbasa','landjaeger'],
	nextButton: '[data-shift="prev"]',
	prevButton: '[data-shift="next"]',
	indexDisplay: '',
	maxshown: 8,
	chartType: 'Bar'
});

// HALTED UNTIL ADJUSTMENT IS MADE TO THE PLUGIN TO SUPPORT MULTIPLE DATASETS

scrollablechart's People

Contributors

ivanbylinkin avatar

Watchers

 avatar

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.