Documentation
You can find this library on npm. This README provides a quick overview of how to use Phoenix. For more detailed information, please see the official documentation. If you are looking to build a Domo Dev Studio app that can query data from Domo and visualize it with Phoenix, please refer to the official Starter Kit.Installation
The Phoenix library is available on npm: @domoinc/domo-phoenix on npm.Usage
Import and use the library in your project:Configuration
Chart Options
The following options are customizable, along with their default values:| Property | Description | Type | Default |
|---|---|---|---|
| width | The width of the Phoenix Chart | number | 500 |
| height | The height of the Phoenix Chart | number | 400 |
| animate | Whether or not the chart should animate in when being drawn | boolean | true |
| colors | An array of hex codes to use in drawing charts. Overrides the default color palette | Array of strings | null |
Chart Types
An enum,CHART_TYPE, is provided with all supported chart types. Here are a few examples of common chart types:
BARSTACKEDBARHORIZ_BARLINECURVED_LINESTACKED_AREANAUTILUSPIEFUNNELBUBBLEDONUTWORD_CLOUD
Data Types
An enum,DATA_TYPE, is provided with all supported data types. Here are the supported data types:
STRINGDOUBLELONGDECIMALDATEDATETIMETIME
Mappings
To correctly map your data to the chart, you must provide a mapping for each column. TheMAPPING enum is used for this purpose. The following mappings are supported:
ITEM: In a bar chart, this would be your x axisVALUE: In a bar chart, this would be your y axisSERIES: This is how your data is grouped
Chart Properties
All Phoenix charts have default properties set to make your chart look great. You can override these properties, if desired. Examples of overrides include the chart’s font size, whether or not to show the “Other” category, bar widths, and more. You can use them like so:Color Palettes
By default, the chart will use Domo’s color palette. You can optionally specify your own custom color palette for your chart by passing an array of hex code strings in your options object. This example shows how to create a chart with a custom color palette of various shades of blue:Chart Methods
The following methods are supported in addition to those shown above:render()
This method performs the actual rendering of the chart on the canvas. Your chart will not appear until you have called this method.resize(width, height)
Theresize method allows you to resize your chart to any width and height (in pixels).
update(data, options?)
Theupdate method allows you to provide a new data object, which will update your chart to reflect those changes. Note: You do not need to call render() again; this method does that for you.
update method. In this object, you can pass an array of colors for a new color palette, as well as a map of chart property overrides, like so:
setChartProperties(properties)
You can pass your chart new properties at any time and it will re-render accordingly. Simply pass an object of property keys and values to the method.resetColorPalette()
This method allows you to reset your chart’s color palette back to the default Domo color palette. Your chart will automatically redraw with the Domo color palette.addEventListener(type, (event) => boolean)
Attach a handler to various Phoenix event types. The following events are supported:drillhoverchartStateChangedcardbus
setUsePhoenixHover(flag)
Have Phoenix render hover tooltips (true by default):