CanvasJS

This section is regarding Methods and Properties available in the CanvasJS namespace.

Examples:
    CanvasJS.formatNumber(10004, “#,###”);
Note:
  • These are static methods under CanvasJS namespace and hence it can be used directly without instantiating a StockChart. Hence you can also use it outside the StockChart too for formatting number / date.
  • Can be very useful inside Custom Formatter Functions.

Methods in CanvasJS namespace

Method Description Example
formatNumber(Number value [,String formatString] [,String culture]) Formats number according to the given formatString. CanvasJS.formatNumber(10000, “#,###”);
formatDate(Date date/timestamp [,String formatString] [,String culture]) Formats date/timestamp according to the given formatString. CanvasJS.formatDate(new Date(), “DD-MM-YY”);
addColorSet(String colorSetName, Array colorSetArray) Adds custom colorSet to the library. CanvasJS.addColorSet(“customColorSet1”, [“#4661EE”, “#EC5657”]);
addCultureInfo(String cultureName, Object cultureOptions) Adds custom culture to the library. CanvasJS.addCultureInfo(“es”, { decimalSeparator: “.” });

To know more about date format string, please refer to this section.

To know more about adding custom culture, info please refer to this section.

Please refer to CanvasJS page for more information about the attributes / properties available.



If you have any questions, please feel free to ask in our forums.Ask Question