anaef opened a new issue, #21686:
URL: https://github.com/apache/echarts/issues/21686

   ### 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to