Skip to content
Francois Vancoppenolle edited this page Jun 28, 2014 · 14 revisions

Previous Chapter          Previous Page          Table of content

format.js

As described in chapter Format, you can write your own formats. The format.js contains a function fmtChartJSPerso with some usefull pre-defined formats.

If you want to use those pre-defined formats, you have to include "Add-ins\format.js" in your html file just after the include of ChartNew.js.

Here after, you will find the list of formats defined in format.js.

A sample that uses the format.js add-in can be found in Samples\add-ins_format.html.

date

When the value to be formatted is a date/time value, you can easely change the form that the value is displayed.

If you specify "date" as format, the date/time value will be displayed as a date under the default format of your device.

Example :

var datedata = {
                labels: [new Date(2014,0,1,12,0,0), new Date(2014,1,1,12,15,0), new Date(2014,2,1,12,30,0), new Date(2014,3,1,12,45,0)],
                datasets: [
                    {
                        fillColor: "rgba(220,0,0,0.5)",
                        strokeColor: "rgba(220,220,220,0.5)",
                        data: [20,10,47,35]
                    },
                    {
                        fillColor: "rgba(0,220,0,0.5)",
                        strokeColor: "rgba(220,220,220,0.5)",
                        data: [13,43,55,33]
                    },
                    {
                        fillColor: "rgba(0,0,220,0.5)",
                        strokeColor: "rgba(220,220,220,0.5)",
                        data:[45,37,39,41]
                    }
                ]
            }

Without format, the graph is displayed like this :

var myLine = new Chart(document.getElementById("canvas_line1").getContext("2d")).Line(datedata,{ graphTitle : "No Date Format",animation :false});

fmtdate

time

fmttime

Previous Chapter          Previous Page          Top of Page

Clone this wiki locally