[Chartjs]-How to import Patternomaly into Ionic 2 project?

4👍

first, install patternomaly via npm :

npm install patternomaly --save

then, import pattern from patternomaly in your chart component :

import pattern from 'patternomaly';

and finally, set the backgroundColor property for your dataset accordingly, as mentioned in the doc :

datasets: [{
   data: [300, 50, 100],
   backgroundColor: [
      pattern.draw('square', '#1f77b4'),
      pattern.draw('circle', '#ff7f0e'),
      pattern.draw('diamond', '#2ca02c')
   ]
}]

see a working example.

Leave a comment