Coder Social home page Coder Social logo

nikoskalogridis / chartist-plugin-axistitle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexstanbury/chartist-plugin-axistitle

0.0 2.0 0.0 23 KB

Plugin for Chartist.js allowing you to add a title to an axis.

License: Do What The F*ck You Want To Public License

JavaScript 89.63% HTML 10.37%

chartist-plugin-axistitle's Introduction

Axis title plugin for Chartist.js

This plugin allows the creation and placement of axis titles. The plugin will throw an error if it is applied to a chart that contains no axes, such as a Pie chart.

In order to use it, you will need to include the excellent charting library Chartist.js in your page.

http://gionkunz.github.io/chartist-js/index.html

Available options and their defaults

var defaultOptions = {
  // The title to be displayed on the axis. If at least one axis title is not supplied then an error is thrown.
  axisTitle: '',
  
  // One or more class names to be added to the axis title. Multiple class names should be separated by a space.
  axisClass: 'ct-axis-title',
  
  // How much to offset the title by. 
  // Please note, x and y offset values for axisY are flipped due to the rotation of the axisY title by 90 degrees. 
  // Therefore changing the x value moves up/down the chart, while changing y moves left/right.
  offset: {x:0, y:0},
  
  // Defines the anchoring of the title text. Possible values are 'start', 'end' and 'middle'.
  textAnchor: 'middle',

  // Whether to flip the direction of the text. Note - This can only be used on axis Y.
  flipText : false
  
};

Sample usage

var chart = new Chartist.Line('.ct-chart', {
            labels: ['0-15', '16-30', '31-45', '46-60', '61-75', '76-90', '91-105', '106-120'],
                series: [1, 3, 7, 12, 1, 2, 1, 0]
            }, {
                chartPadding: {
                    top: 20,
                    right: 0,
                    bottom: 20,
                    left: 0
                },
                axisY: {
                    onlyInteger: true
                },
                plugins: [
                    Chartist.plugins.ctAxisTitle({
                        axisX: {
                            axisTitle: 'Time (mins)',
                            axisClass: 'ct-axis-title',
                            offset: {
                                x: 0,
                                y: 50
                            },
                            textAnchor: 'middle'
                        },
                        axisY: {
                            axisTitle: 'Goals',
                            axisClass: 'ct-axis-title',
                            offset: {
                                x: 0,
                                y: -1
                            },
                            flipTitle: false
                        }
                    })
                ]
            });

chartist-plugin-axistitle's People

Contributors

alexstanbury avatar

Watchers

 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.