Skip to main content
Build beautiful charts using Phoenix, Domo’s powerful charting engine for Domo Apps.

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:
PropertyDescriptionTypeDefault
widthThe width of the Phoenix Chartnumber500
heightThe height of the Phoenix Chartnumber400
animateWhether or not the chart should animate in when being drawnbooleantrue
colorsAn array of hex codes to use in drawing charts. Overrides the default color paletteArray of stringsnull

Chart Types

An enum, CHART_TYPE, is provided with all supported chart types. Here are a few examples of common chart types:
  • BAR
  • STACKEDBAR
  • HORIZ_BAR
  • LINE
  • CURVED_LINE
  • STACKED_AREA
  • NAUTILUS
  • PIE
  • FUNNEL
  • BUBBLE
  • DONUT
  • WORD_CLOUD

Data Types

An enum, DATA_TYPE, is provided with all supported data types. Here are the supported data types:
  • STRING
  • DOUBLE
  • LONG
  • DECIMAL
  • DATE
  • DATETIME
  • TIME

Mappings

To correctly map your data to the chart, you must provide a mapping for each column. The MAPPING enum is used for this purpose. The following mappings are supported:
  • ITEM: In a bar chart, this would be your x axis
  • VALUE: In a bar chart, this would be your y axis
  • SERIES: 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:
By passing these options, your chart will be customized to those settings.

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:
You can pass as few or as many colors as you like in this array. Phoenix will start with the first color in the list and move down the array. If it runs out of colors, it will loop back to the beginning. For best visual results, provide enough different colors to cover the scope of your data. To update your color palette or reset to the default, see the API documentation.

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)

The resize method allows you to resize your chart to any width and height (in pixels).

update(data, options?)

The update 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.
You may also optionally provide the options object to the 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:
  • drill
  • hover
  • chartStateChanged
  • cardbus

setUsePhoenixHover(flag)

Have Phoenix render hover tooltips (true by default):