GithubHelp home page GithubHelp logo

divcharts's Introduction

DIVCharts - SVG/Canvas-less Bar Charts

DIVCharts allows you to create vertical bar charts without needing to use SVG or Canvas elements

<head> section includes

<link rel="stylesheet" type="text/css" href="divcharts.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="plugins/jquery.hoverIntent.minified.js"></script>
<script type="text/javascript" src="divcharts.js"></script>

Usage

var chart = $('container').DivChart({ options });

Customization Options

Required Options:~~~~~~~~~~~~~~~~~~~~~

labels: (Default: [])

  • An array of X-axis labels

Optional Options:~~~~~~~~~~~~~~~~~~~~~

values: (Default: [])

  • An array of numeric values. If no values are initially given, they must be added using the update function.

width: (Default: '95%')

  • Number (in pixels) or a percentage

height: (Default: 300)

  • Number (in pixels) or a percentage

ymin: (Default: 0)

  • Integer value

ymax: (Default: 100)

  • Integer value

colors: (Default: ['#AA4643','#89A54E', '#80699B', '#3D96AE', '#DB843D'])

  • An array of color strings (must be at least the number of labels you have).

Functions

init({<options>}) - Called when the DIVChart is instanciated.

  • options: (see above)

Example:

//instanciate the chart
var chart = $('container').DivChart({ ... });

update({ values: [<numbers>], index: <int> }) - Used to update bar values.

  • values: Array of numbers to set on the chart
  • index: Optional. Where the update starts. No index means 0.

Example:

//update 2nd and 3rd categories
chart.DivChart('update', {values: [5,10], index: 1});

stop() - Call this to clean up the animation queue if you're changing values frequently.

destroy() - Call this to clean up the chart from the DOM.

Chart Variables available to the user (dcvars)

  • width: Actual width of the chart
  • height: Actual height of the chart
  • labels: Labels used to set up the chart
  • max: Y-max value
  • min: Y-min value
  • barHeights: An array of the heights of the bars (in pixels)
  • currValues: An array of the current values of the bars in the chart

Example Usage:

chart.dcvars.barHeights

Want to animate your chart? It's easy! Check out graph_test.html to see how!

Enjoy!

divcharts's People

Contributors

jrtitus avatar

Watchers

 avatar  avatar  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.