All Products
Search
Document Center

MaxCompute:Visualize data on a dashboard

Last Updated:Mar 26, 2026

The DataAnalysis module in DataWorks includes a built-in visualization tool that turns SQL query results into charts. This tutorial walks you through querying user persona data from MaxCompute and configuring four charts: a stacked bar chart and three pie charts.

Prerequisites

Before you begin, ensure that you have:

  • Processed the source data using DataWorks DataStudio. For details, see Process data

  • A MaxCompute data source configured in your workspace

  • Permission to query the data source. If not, go to Security Center > Security policy > Data query and analysis control > Queryable data source, find your data source, and click Authorization in the Operation column. For details, see Security Center

Chart types covered

This tutorial demonstrates the following chart types:

Chart typeUse case
Stacked horizontal bar chartNumbers of registered members by province
Pie chartDistribution of member page views by age
Pie chartDistribution of page views by gender
Pie chartPage views by gender and zodiac sign

Open SQL query

  1. Log on to the DataWorks console.

  2. In the top navigation bar, select your region.

  3. In the left-side navigation pane, choose Data Analysis and Service > DataAnalysis, then click Go to DataAnalysis.

  4. In the left-side navigation pane of DataAnalysis, click SQL Query.

Set up a data source and run a query

  1. Create a temporary file.

    • If this is your first time on the SQL Query page, or no SQL file is open, click Create SQL Query.

    • If an SQL file is already open, click the image.png icon to create a new temporary file.

    For more about SQL Query, see SQL Query (Legacy).
  2. On the temporary file's edit page, select your workspace, engine type, and data source. This tutorial uses a MaxCompute data source.

  3. Enter the following SQL statement and click the image.png icon to run the query. This queries all columns from the ads_user_info_1d table for a specific partition.

    -- If the target partition is not found, run: show partitions ads_user_info_1d
    select * from ads_user_info_1d where dt='data timestamp';

Configure charts

After the query completes, click the image.png icon in the left panel to switch to chart view. To open the full chart editor, click the image.png icon in the upper-right corner.

image.png

Each chart follows the same workflow: set a title, choose a chart type, assign data fields, and save.

Registered members by province

This chart shows the number of distinct registered members per province as a stacked horizontal bar chart.

Configuration summary:

SettingValue
Chart typeStacked Hori Bar Chart
X-axis fielduid — Aggregation: Distinct
Y-axis fieldregion
X-axis titleNumber of Registered Members
Y-axis titleProvince

Steps:

  1. Double-click the default chart title and enter a new title.

  2. In the right-side panel, choose Style > Chart morph > Stacked Hori Bar Chart.

  3. In the left-side panel, click Data and assign the fields:

    1. Drag uid to X-axis. From the X-axis drop-down, choose Aggregation > Distinct.

    2. Drag region to Y-axis.

  4. Rename the axis titles:

    1. In the right-side panel, click Style > Global Settings > Detailed > Detailed > Chart Styles.

    2. Click Axis Title for the X-axis and change the title from uid to Number of Registered Members.

    3. Click Axis Title for the Y-axis and change the title from region to Province.

  5. Click Save in the upper-right corner.

    image.png

    image.png

Member page views by age

This chart shows the distribution of total page views across age groups as a pie chart.

Configuration summary:

SettingValue
Chart typePie Chart
Type fieldage_range
Value fieldpv — Aggregation: Sum

Steps:

  1. Double-click the default chart title and enter a new title.

  2. In the right-side panel, choose Style > Chart morph > Pie Chart.

  3. In the left-side panel, click Data and assign the fields:

    1. Drag age_range to Type.

    2. Drag pv to Value. From the Value drop-down, choose Aggregation > Sum.

  4. Click Save in the upper-right corner.

    image.png

    image.png

Member page views by gender

This chart shows the distribution of total page views by gender as a pie chart.

Configuration summary:

SettingValue
Chart typePie Chart
Type fieldgender
Value fieldpv — Aggregation: Sum

Steps:

  1. Double-click the default chart title and enter a new title.

  2. In the right-side panel, choose Style > Chart morph > Pie Chart.

  3. In the left-side panel, click Data and assign the fields:

    1. Drag gender to Type.

    2. Drag pv to Value. From the Value drop-down, choose Aggregation > Sum.

  4. Click Save in the upper-right corner.

    image.png

    image.png

Page views by gender and zodiac sign

This chart breaks down page views by gender and zodiac sign, using gender on the X-axis and zodiac sign as the trace dimension.

Configuration summary:

SettingValue
Chart typePie Chart
X-axis fieldgender
Y-axis fieldpv — Aggregation: Sum
Trace fieldzodiac
X-axis titleGender
Y-axis titlePage Views

Steps:

  1. Double-click the default chart title and enter a new title.

  2. In the right-side panel, choose Style > Chart morph > Pie Chart.

  3. In the left-side panel, click Data and assign the fields: image.png

    1. Drag gender to X-axis.

    2. Drag pv to Y-axis. From the Y-axis drop-down, choose Aggregation > Sum.

    3. Drag zodiac to Trace.

  4. Rename the axis titles:

    1. In the right-side panel, click Style > Global Settings > Chart Information > Detailed > Chart Styles.

    2. Click Axis Title for the X-axis and change the title from gender to Gender.

    3. Click Axis Title for the Y-axis and change the title from pv to Page Views.

  5. Click Save in the upper-right corner.

    image.png

    image.png

What's next

After saving your charts, share or revisit them from the DataAnalysis home page.

  1. Click Save in the upper-right corner of any chart to save and share it.

    image.png

  2. To view saved charts, go to the DataAnalysis page and click the image icon in the sidebar.

    image.png