# XY Chart

## Render Types

XY charts support the following render types, as well as composite charts that combine them.

| <p>Line </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-aa0fd7c5dde464aabbb143774a9e1ce52f3ae938%2Fxy-line-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-d0a9ee2d141544d9a9bc88883811d3d2d8779143%2Fxy-line-light.png?alt=media" alt="XY Line"></picture></p>             | <p>Bar </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-eeca63efb1cd2de12e730023ef9e741ddae4866a%2Fxy-bar-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-9f883646c81e4d79290853609ab65dc2203ecd16%2Fxy-bar-light.png?alt=media" alt="XY Bar"></picture></p>                                   | <p>Stacked Bar </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-7552b5604e3c8a4911d2a6cb64c6d6825477e038%2Fxy-stackedbar-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-eba052d98ae2a42e83e150f8d3d3f5808cb1f1c5%2Fxy-stackedbar-light.png?alt=media" alt="XY Stacked Bar"></picture></p>          |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Area </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-915c97e720e381ce49b73921f87a33a6baed115f%2Fxy-area-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-6352ec9507df8b49f69b5013c1ff3f75cf7b1d55%2Fxy-area-light.png?alt=media" alt="XY Area"></picture></p>             | <p>Stacked Area </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-b3c4229e75d69a500a425327f3b370f9d51905b9%2Fxy-stackedarea-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-fcd025652e35f5a5059848b8bc5b31dac9c8cd6d%2Fxy-stackedarea-light.png?alt=media" alt="XY Stacked Area"></picture></p> | <p>100% Stacked Bar </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-1dace1b2ac03cde2727bb80d8425136bae793b12%2Fxy-percentbar-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-a1862f06829d9e29b03cb25f013a0dbb9c0c0dda%2Fxy-percentbar-light.png?alt=media" alt="XY Percent Bar"></picture></p>     |
| <p>Scatter </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-84b4276692ab63a9201a5c2881ce279fee81e841%2Fxy-scatter-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-2d1be4013832902422f5f3dfd6365d11a8f6d70d%2Fxy-scatter-light.png?alt=media" alt="XY Scatter"></picture></p> | <p>Bubble </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-f6f553409d02c16dd5f3f27d3f134a883e5d4dc6%2Fxy-bubble-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-c59b082ff6dde6a4c6ed85e8efbd620b72e389a2%2Fxy-bubble-light.png?alt=media" alt="XY Bubble"></picture></p>                       | <p>100% Stacked Area </p><p><picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-7bede2c4af1de0b92968e359b7223872852fb72e%2Fxy-percentarea-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-7a9b09c0738a5175a75f1295d8de57b2c9aa3dfe%2Fxy-percentarea-light.png?alt=media" alt="XY Percent Area"></picture></p> |

## Specifications

### Aggregation <a href="#xy-xyz-diff" id="xy-xyz-diff"></a>

In XY charts, the [X-axis is a dimension and the Y-axis is a metric](https://docs.codatum.com/data-exploration/chart-common#dimension-metric), and Y-axis values are aggregated for each X-axis value. (In [XYZ charts](https://docs.codatum.com/data-exploration/chart/xyz-chart), the X-axis and Y-axis are dimensions and the Z-axis is a metric, so Z-axis values are aggregated for each combination of X and Y.)

| Item        | Role      | Notes                               |
| ----------- | --------- | ----------------------------------- |
| X-axis      | Dimension | Aggregation unit (aggregated per X) |
| Y-axis      | Metric    | Adds a series per metric            |
| Grouping    | Dimension | Splits series by value              |
| Bubble size | Metric    | Only for bubble rendering           |

#### Example Configurations

* Show "Monthly total sales" as a line chart
  * X-axis (Dimension): Month
  * Y-axis (Metric): Total sales
* Show "Total sales by product category" as a bar chart
  * X-axis (Dimension): Product category
  * Y-axis (Metric): Total sales

### X-Axis Specifications <a href="#x-axis" id="x-axis"></a>

In XY charts, the X-axis type is determined by the **X-axis data type** and the **render type composition**.

| X-axis data type | Render type composition   | X-axis classification |
| ---------------- | ------------------------- | --------------------- |
| Date/Datetime    | All                       | Time axis             |
| Numeric          | Scatter/Bubble/Line only  | Numeric axis          |
| Numeric          | Includes Bar/Area/Stacked | Categorical axis      |
| Other            | All                       | Categorical axis      |

#### Categorical Axis <a href="#axis-category" id="axis-category"></a>

In a categorical axis, even if the specified values are numeric or date/datetime types, they are rendered as discrete values at equal intervals.

**Specifying Axis Upper and Lower Limits**

When specifying upper or lower limits for a categorical axis, the specified values are treated as indices of the data order (0th, 1st, 2nd...).

| Index | X-axis value |
| ----- | ------------ |
| 0th   | `1`          |
| 1st   | `10`         |
| 2nd   | `20`         |
| 3rd   | `30`         |
| ...   | ...          |
| 10th  | `100`        |

In this case, if you set the axis upper limit to `10`, data up to the 10th index will be displayed, which means X-axis values up to `100` will be shown.

#### Time Axis <a href="#axis-time" id="axis-time"></a>

In a time axis, the specified date/datetime type data is rendered as a continuous time series.

* Axis labels are dynamically determined based on the specified date/datetime data
* When datetime data with a timezone is specified, it is converted to the timezone specified in the browser for rendering
  * Axis labels are displayed based on the browser time zone. Therefore, if the browser time zone does not match the data time zone, axis labels and data labels may be misaligned
  * Converting to a datetime format without a time zone can also prevent the browser time zone from affecting the dates and times

#### Numeric Axis <a href="#axis-value" id="axis-value"></a>

In a numeric axis, the specified numeric type data is rendered as continuous numeric values.

## Tips

### Multiple Series <a href="#multiple-views" id="multiple-views"></a>

When you configure multiple series, a "Indepedent scale" option appears in the series settings. Turning it on gives that series its own Y-axis scale, drawn on the right.

Configure labels and other options for independent Y-axes under "Advanced" > "Independent axes".

| <picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-8dd1d4fce2fa672c0683e46764dd692ab4938459%2Fxy-mixed-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-4652c1c8fb50bc5e968d523fac0930027fe1b6ab%2Fxy-mixed-light.png?alt=media" alt="XY chart with multiple series and independent Y-axes"></picture> |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

When you configure multiple series, a "Split by series" option appears below the "Series" settings. Turning it on gives each series its own Y-axis scale and stacks the charts vertically, one per series.

Enabling "Split by series" disables the [frame feature](#frame-feature). The "Indepedent scale" option is also hidden, and every series is treated as having an independent axis. Configure per-series Y-axes under "Advanced" > "Independent axes".

| <picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-3587515585313568ee77d2f01854f19cbc53e88a%2Fxy-mixed-split-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-e8a75fb176a39477237d059ff35e53011b5cfeda%2Fxy-mixed-split-light.png?alt=media" alt="XY chart with split view by series"></picture> |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

### Frame Feature <a href="#frame-feature" id="frame-feature"></a>

XY charts support the frame feature. See [Frame Feature](https://docs.codatum.com/data-exploration/chart-common#frame-feature) for details.

### Reference Line <a href="#reference-line" id="reference-line"></a>

In XY Charts and XYZ Charts, you can add reference lines to the X-axis and Y-axis. By displaying reference lines or regions such as target values, acceptable ranges, or danger zones, you can visually support data evaluation. Y-axis reference lines are displayed horizontally, and X-axis reference lines are displayed vertically.

| <picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-ddfb205ed689f42b9c138f2957044ac2a971ef8a%2Fxy-reference-line-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-583fe75bbf33f104f3547d1873ad59a936f1fb71%2Fxy-reference-line-light.png?alt=media" alt="XY Reference Line"></picture> |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

* Configuration Method
  * In the chart edit screen "Advanced Settings", select the axis where you want to display the reference line, then click "Reference Line" > "Add". Enter the type and value of the reference line you want to display.
* What You Can Do
  * Line: Display a dashed line at a specific value (e.g., sales target, threshold, specific date marker)
  * Band (Range): Display a semi-transparent band for a specific range (e.g., acceptable range, danger zone, caution period)
  * Color and Label Settings: Choose colors from success (green), warning (yellow), danger (red), and add labels as needed

### Trend <a href="#trend" id="trend"></a>

In XY Charts and XYZ Charts, you can display trend lines (such as regression lines or moving averages) for series. Trend lines are added as separate series from the original data, helping you visually understand data trends.

| <picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-f72fe6ec616d860ca0886e46c172df48f833085e%2Fxyz-trendline-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-680c705d6d99c778a8dc371209ad13bd5a1c9bba%2Fxyz-trendline-light.png?alt=media" alt="XYZ Trend"></picture> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

* Configuration Method
  * In the chart edit screen "Advanced Settings", click "Series" > "Trend" > "Display" and select the type of trend you want to display.
  * Trend lines are displayed as dashed lines, and for trend types other than moving average, the equation and R² (coefficient of determination) are displayed on the chart. (The coefficient of determination can be hidden.)

#### Trend Types

| Trend Type     | Description                                       | Additional Settings        |
| -------------- | ------------------------------------------------- | -------------------------- |
| Linear         | Displays linear regression (y = mx + c)           | None                       |
| Polynomial     | Displays polynomial regression                    | Specify degree from 2 to 5 |
| Moving Average | Displays moving average                           | Specify window size        |
| Exponential    | Displays exponential regression (y = ae^(bx))     | None                       |
| Logarithmic    | Displays logarithmic regression (y = a + b ln(x)) | None                       |
| Power          | Displays power regression (y = ax^b)              | None                       |

Note: Trend lines will not be displayed if the data count is insufficient or if applying the specified trend type fails.

### Statistics <a href="#statistics" id="statistics"></a>

In XY Charts and XYZ Charts, you can display statistical values (mean, median, maximum, minimum) of series as dashed lines.

| <picture><source srcset="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-96f3cd8c359d23f5b60ba7ab9454b4a4524d2c96%2Fxy-stats-dark.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-1ea52a027d895e1ba1ed816c806ddfb81d4d77ec%2Fxy-stats-light.png?alt=media" alt="XY Statistics"></picture> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

* Configuration Method
  * In the chart edit screen "Advanced Settings", click "Series" > "Statistics" > "Display" and select the statistical values you want to display.
  * The dashed lines will display the statistics type and its value as labels.

#### Difference from Trends

| Feature            | Statistics                                       | Trend                                       |
| ------------------ | ------------------------------------------------ | ------------------------------------------- |
| Display Format     | Displayed as the same series                     | Added as a separate series (trend line)     |
| When Zooming Chart | Recalculated only with data in the visible range | Not recalculated (always based on all data) |
| In Stacked Charts  | Appears as a stacked differential                | Not stacked                                 |
