Giter Site home page Giter Site logo

sparklinerjs's Introduction

SparklinerJS โ€” an easy way to make a sparkline graph in web

A sparkline is a very small line chart, typically drawn without axes or coordinates. It presents the general shape of the variation (typically over time) in some measurement, such as temperature or stock market price, in a simple and highly condensed way.

SparklinerJS

Three simple steps

  1. Downoload it;
  2. Add sparkliner.js to your page;
  3. Create a new sparkline object and set it up.

When you did it you can get something like this:

SparklinerJS

๐Ÿ”ฅLive demo

How to add sparkliner.js to my page

You should just paste a sparkliner.js link above </body>. It's really important. Don't forget it.

<!-- A SparklinerJS link -->
<script src="js/sparkliner.js"></script>
<!-- A user sparkline settings link -->
<script src="js/myScript.js"></script>
<!-- A closed body tag -->
</body>

How to create a sparkline

It's easy. Just do something like that:

// Create a data array for our sparkline
var myArray = [10, 30, 3, 8, 39, 25, 22, 89, 74, 7, 2, 40, 61, 17, 35, 31, 8, 14, 39, 32, 53]
// Create a sparkline object
var mySparkliner = new Sparkliner()
// Define an html element ID for a sparkliner. It's place where we'll append our sparkliner
mySparkliner.id = "sparkliner"
// Pass an array and create SVG
mySparkliner.create(myArray)

How to customize a sparkline

You can change following a sparkline property:

// A stroke color
mySparkliner.strokeColor = "#0000ff"
// A stroke width
mySparkliner.strokeWidth = 2
// Show a circle marker or not
mySparkliner.circleShow = true
// A circle marker color
mySparkliner.circleColor = "#ffff00"
// A circle marker radius
mySparkliner.circleRadius = 6

Also you can define width and height of a sparkline canvas. But by default this parameters are defined by an html element (where we append our sparkliner).

// Width and height
mySparkliner.width = 600
mySparkliner.height = 160

Links

Linkedin | Dribbble | Facebook

sparklinerjs's People

Contributors

volorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nvdnkpr eikes

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.