Giter Club home page Giter Club logo

chartjs-cfc's Introduction

chartjs-cfc

CFC wrappers for ChartJS - easily draw bar charts, pie charts, line graphs, and scatter plots

chartjs-cfc makes it easier to use ChartJS in your ColdFusion/Lucee projects. It supports bar graphs, horizontal bar graphs, line graphs, pie charts, and scatter plots and a limited set of ChartJS display options. It uses patternomaly to automagically generate textures as well as colors for your charts.

How to use it

Install ChartJS and patternomaly. Get them from npm or include from a CDN:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/patternomaly.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script>

Init a bar chart:

<cfset myData = [
    [12,10,14,15,10],
    [20,9,23,16,18],
    [3,7,4,5,6]
]>
<cfset dataLabels = [ "January","February","March","April","May" ]>
<cfset datasetNames = [ "Boys","Girls","Adults" ]>
<cfset myBarChart = new chartjs-cfc.BasicChart( data=myData, dataLabels=dataLabels, datasetNames=datasetNames )>

Output a <div> element containing the chart <canvas> and the <script> to draw it:

#myBarChart.draw( title="Attendance by month for Boys, Girls, and Adults", width=75 )#

The <div> is relatively positioned and scales against its parent element. init() and draw() accept a variety of arguments to customize chart type and appearance. See examples

Future improvements?

  • Add support for time scaling
  • Show point labels on scatter plots and provide more display options
  • Automatically add line dashing to multi-dataset line graphs
  • Automatically calculate range of axes
  • Generate aesthetically pleasing color palettes rather than picking from a list

chartjs-cfc's People

Contributors

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