Step 1: Set Up Your Pro-Code Environment
- Create a New Project in Pro-Code Editor:



-
File Structure:
- The following files are created automatically in your project:
index.htmlapp.jsapp.cssmanifest.json
- You can modify the
manifest.jsonusing the JSON Editor by clicking ‘Edit in JSON Editor’ at the top right of the file, or by using the GUI by using the GUI Editor. This will be explained in the next section.
- The following files are created automatically in your project:
Step 2: Define the Manifest File (manifest.json)
The manifest.json file defines your app’s metadata and data mappings in Domo. Update it according to your dataset’s structure.
-
Stacks- the name of the stack (e.g. “Stack A”, “Stack B”, etc.) -
Bar1- the value for the first bar -
Bar2- the value for the second bar -
Bar3- the value for the third bar -
Date- the date for the data point -
Extra1- an extra column for additional data. -
Extra2- an extra column for additional data. -
Both
Extraare used for the trended line calculation.
| Stacks | Bar1 | Bar2 | Bar3 | Date | Extra1 | Extra2 |
|---|---|---|---|---|---|---|
| Stack A | 10 | 20 | 30 | 2022-01-01 | 1 | 2 |
| Stack B | 40 | 50 | 60 | 2022-01-02 | 3 | 4 |

Step 3: Structure Your HTML (index.html)
The index.html file contains the structure of your app, including the canvas element where the chart will be rendered.
Step 4: Define the Styling (app.css)
The app.css file will control the appearance of your chart container, including making it scrollable.
Step 5: Write the JavaScript Logic (app.js)
This section covers the main logic of the app. To modularize the code and improve readability, we’ll break the logic into separate functions.
Step 5.1: Fetch and Prepare Data
domo.get('/data/v1/dataset')retrieves the dataset from Domo.- The
prepareDatafunction processes this data to extract labels, stacks, and categories.
Step 5.2: Define Colors and Create Datasets
- This function creates datasets for each stack and category by mapping over labels and filtering data accordingly.
Step 5.3: Calculate the Trended Line Data
- This function calculates the trend percentage for each label and adds the trended line to the datasets.
Step 5.4: Create the Chart with Chart.js
- This function sets up and renders the chart using Chart.js, with customizable options and Datalabels plugin for better visualization.
- Each
legendobject inside theoptionsobject configures a legend or label for the chart. For example,plugin.datalabels.labels.legendspecifies will customize the label for each bar in the chart.

Step 6: Save and Test Your App
- Deploy the App:
- Save all files in the Pro-Code Editor.
- Create a new card based on the Asset created by Pro-Code Editor.
- Wire a dataset to the card within Domo.
- Test the App:
- Navigate to the card.
- Verify that the chart displays correctly with the stacked bars and trended line.
Conclusion
Congratulations! You’ve successfully built a stacked bar chart with a trended line in Domo’s Pro-Code Editor. This tutorial provided you with the foundational steps to create a custom chart using JavaScript, Chart.js, and Domo’s data platform. Feel free to customize and expand on this tutorial to fit your specific needs.