npm install mjml-chart     !extra
Displays charts as images in your email. Note that the chart can be animated (gif) when the chan attribute is specified.
#### 🎩 Usage
``xml`
##### 🚀 Setup
- mjml-chart v5.x.x is built for MJML4 (Community components):
`bash
npm install mjml-chart@5 --save
cat <
{
"packages": [
"mjml-chart/lib/index.js"
]
}
EOF
`
- mjml-chart v4.x.x is built for MJML3:
`bash`
npm install mjml-chart@4 --save
##### 🚧 Documentation
| attribute | description | value examples |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| cht | Chart type | bvg, p |a:-100,200.5,75.55,110
| chd | chart data | , t:10,20,30\|15,25,35, s:BTb19_,Mn5tzb, e:BaPoqM2s,-A__RMD6 |-80,140
| chds | data format with custom scaling | |UTF-8
| choe | QRCode data encoding | |L\|4
| chld | QRCode error correction level and optional margin | , M\|10, Q\|5, H\|18 |0,0,200
| chxr | Axis data-range | , 0,10,50,5, 0,0,500\|1,0,200 |.png
| chof | Image output format | , .svg, .gif |400x400
| chs | Chart size ( |NASDAQ\|FTSE100\|DOW
| chdl | Text for each series, to display in the legend | |9e9e9e,17
| chdls | Chart legend text and style | |1,1
| chg | Solid or dotted grid lines | , 0,1,1,5, 1,1,FF00FF, 1,1,1,1,CECECE |FFC48C
| chco | series colors | , FF0000,00FF00,0000FF |My beautiful chart
| chtt | chart title | |00FF00,17
| chts | chart title colors and font size | |y
| chxt | Display values on your axis lines or change which axes are shown | , x,y, x,x,y, x,y,t,r,t |0:\|Jan\|July\|Jan
| chxl | Custom string axis labels on any axis | , 0:\|Jan\|July\|Jan\|1\|10\|20\|30 |1,0000DD
| chxs | Font size, color for axis labels, both custom labels and default label values | , 1NcUSDMil,FF0000, 1NcEUR,FF0000, 2,0000DD,13,0,t, 0Npper-month,0000FF, 0Ne,000000\|1NcUSDMil,FF0000\|2N2sz,… |10
| chm | compound charts and line fills | |
| chls | line thickness and solid/dashed style | , 3,6,3\|5 |label1\|label2
| chl | bar, pie slice, doughnut slice and polar slice chart labels | , multi\nline\nlabel1\|label2 |align,top\|offset,10\|color,FF00FF
| chlps | Position and style of labels on data | , align,top\|offset,10\|color,FF00FF |30,30,30,30
| chma | chart margins | , 40,20 |b0,lg,0,f44336,0.3,03a9f4,0.8
| chdlp | Position of the legend and order of the legend entries | |
| chf | Background Fills | |5
| chbr | Bar corner radius. Display bars with rounded corner. | , 10 |1200
| chan | gif configuration | , 1300\|easeInOutSine |95K€
| chli | doughnut chart inside label | , 45% |account_id
| icac | image-charts enterprise | accountId |0785cf22a0381c2e0239e27c126de4181f501d11…
| ichm | HMAC-SHA256 signature required to activate paid features | |Abel
| icff | Default font family for all text from Google Fonts. Use same syntax as Google Font CSS API | , Akronim, Alfa Slab One |normal
| icfs | Default font style for all text | , italic |en
| [iclocale]() | localization (ISO 639-1) | |1
| icretina | retina mode | |FFFFFF
| icqrb | Background color for QR Codes | |000000
| icqrf | Foreground color for QR Codes | |
Since mjml-chart is a wrapper for mjml-image, mjml-image attributes are also available:
| attribute | default values |
| ----------------------------------------- | -------------- |
| alt | n/a |
| name | n/a |
| srcset | n/a |
| sizes | n/a |
| title | n/a |
| rel | n/a |
| align | center |
| border | 0 |
| border-bottom | n/a |
| border-left | n/a |
| border-right | n/a |
| border-top | n/a |
| border-radius | n/a |
| container-background-color | n/a |
| fluid-on-mobile | n/a |
| padding | 10px 25px |
| padding-bottom | n/a |
| padding-left | n/a |
| padding-right | n/a |
| padding-top | n/a |
| max-height | n/a |
| font-size | 13px |
| usemap | n/a |
Note:
- src attribute is not customizable, it's generated by mjml-chartwidth
- and height are automatically generated by mjml-chart based on the chs attribute
If this warning appears in your log when you use mjml-chart, check your mjml` version and be sure you have the last