apache / apache/echarts

[Bug] baseOption with media incorrectly requires TimelineComponent when no timeline is configured

Open
#21,686 1 comment 0 reactions 0 assignees Claimed by @MohammadWasi View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

6.1.0

### Link to Minimal Reproduction

https://jsbin.com/qayihuxedu/edit?html,css,js,output

### Steps to Reproduce

Using the modular ECharts build without registering `TimelineComponent`:

```js
import * as echarts from "echarts/core"
import { LineChart } from "echarts/charts"
import { GridComponent } from "echarts/components"
import { CanvasRenderer } from "echarts/renderers"

echarts.use([
GridComponent,
LineChart,
CanvasRenderer,
])

const chart = echarts.init(document.getElementById("chart"))

chart.setOption({
baseOption: {
xAxis: {
type: "category",
data: ["a", "b"],
},
yAxis: {
type: "value",
},
series: [
{
type: "line",
data: [1, 2],
},
],
},
media: [
{
query: {
maxWidth: 500,
},
option: {
grid: {
left: "10%",
right: "10%",
},
},
},
],
})
```

No timeline is present in this option. The x-axis is also explicitly a category axis.

### Current Behavior

ECharts reports:

```text
Component timeline is used but not imported.
```

Depending on the development environment, this is surfaced as an exception while calling `setOption`.

Registering `TimelineComponent` suppresses the error, even though the chart does not use a timeline.

Charts that pass an ordinary root option work correctly. The issue appears when the responsive option is structured using `baseOption` and `media`.

### Expected Behavior

ECharts should not require `TimelineComponent` unless a timeline is actually configured.

An option containing `baseOption` and `media`, but no `timeline`, should work with the modular build without registering `TimelineComponent`.

### Environment

```markdown

```

### Any additional comments?

### Suspected cause

`OptionManager.parseRawOption` appears to assign the root timeline to the base option even when the value is absent:

```js
if (!baseOption.timeline) {
baseOption.timeline = timelineOnRoot
}
```

When `timelineOnRoot` is `undefined`, this still creates a `timeline` property on `baseOption`.

The missing-component check subsequently appears to treat the presence of the `timeline` key as actual timeline usage, without checking whether its value is `undefined`. It therefore concludes that `TimelineComponent` is required.

### Workaround

Hoisting `baseOption` to the option root avoids the problem:

```js
chart.setOption({
...baseOption,
media,
})
```

Alternatively, registering `TimelineComponent` suppresses the error, but unnecessarily includes a component that the chart does not use.

Contributor guide

Open the contributing guide

Research direction

Start at OptionManager.parseRawOption and trace the missing-component check for options using baseOption and media. Reproduce the modular ECharts example without TimelineComponent, then verify that charts without a timeline no longer require it while ordinary root options and actual timeline configurations retain their expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.