When using Chartisan, every chart have it's own Chartisan instance. You can build the Chartisan instance with additional options that will affect how the chart is first rendered into the screen. Additional configuration for the following re-renders will be managed by the update method. You can create a new Chartisan instance by using it's constructor and passing additional settings to it as an object in the first parameter. Chartisan requires at least two options to be defined in the configuration object. One is the query selector that Chartisan will use to bound the chart to. The query selector will be used to select a DOM element where the chart will be displayed. You can pass the query selector in the
el property as a string or you can pass a DOM element directly, either will work. Additionally you need to define the chart data. You can do this by either passing the
data property with a well formatted data or you can specify a
url property where Chartisan will try fetching the data at.
The chart instance will be created as soon as the constructor is called and attached to the dom.
Chartisan have a loader to indicate that the chart is undergoing some operation. For instance, when the chart is loading or refreshing or even when it failed. Chartisan allows to customize the chart loader in order to fit the needs of your application. You can customize the loader by providing the property
loader in the chart constructor. This property accepts an object with the customization willing to apply.
At the moment, the only available loader type is
Sometimes, charts can fail to display. There are serveral reasons for this, for example, the chart may fail to get the data from the given endpoint, maybe it's offline or the data is an invalid format. Maybe the chart library just failed to initiate the chart, etc. For all those cases, Chartisan got you covered with an fancy error message displayed where the chart should be located. You are free to customize what is displayed and also allows a debug option that can be enabled to get more information on what happened. You can pass the customization options to the
error property on the chart constructor. This property accepts an object with all the available options as shown below.
At the moment, the only available error type is
As explained in the updating charts section, Chartisan allows for customizing how the HTTP request is performed. You can pass a property called
options to the chart constructor and it will be directly passed to the
fetch() function as the second parameter. This allows modifying how the request is performed at a deeper level by having total control of how the HTTP request is performed and allows for instance, appending headers or changing the request method. You can also append query parameters as usual by appending them on the chart URL at the
Keep in mind that if you're using static data without any back-end, those settings will be ignored.