You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "piotrzarzycki21 (via GitHub)" <gi...@apache.org> on 2025/05/13 13:15:26 UTC
[PR] add button positioning capability to DataView component [echarts]
piotrzarzycki21 opened a new pull request, #20969:
URL: https://github.com/apache/echarts/pull/20969
Add buttonPosition option to DataView feature that allows users to customize the position of buttons in the DataView panel. This enhances flexibility by enabling precise positioning using top, right, bottom, and left properties.
Test case added in area-large-dataView.html.
<!-- Please fill in the following information to help us review your PR more efficiently. -->
## Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [x] new feature
- [ ] others
### What does this PR do?
Adds positioning capability to DataView buttons in the toolbox component.
### Fixed issues
<!--
- #xxxx: ...
-->
## Details
### Before: What was the problem?
Previously, the DataView buttons were fixed at the bottom right of the panel with a hardcoded style: `position:absolute;bottom:5px;left:0;right:0`. Users had no way to customize the position of these buttons to match their UI requirements.
### After: How does it behave after the fixing?
After this change, users can specify exact positioning for the DataView buttons using the `buttonPosition` property which leverages the existing `BoxLayoutOptionMixin` type. This allows precise control over the top, right, bottom, and left positioning of the buttons.
Example usage:
```
option = {
toolbox: {
feature: {
dataView: {
readOnly: false,
lang: ['Cancel', 'OK', 'View data'],
buttonPosition: {
right: '5px',
top: '5px'
}
}
}
}
}
```
## Document Info
One of the following should be checked.
- [ ] This PR doesn't relate to document changes
- [x] The document should be updated later
- [ ] The document changes have been made in apache/echarts-doc#xxx
## Misc
### ZRender Changes
- [x] This PR doesn't depend on ZRender changes.
### Related test cases or examples to use the new APIs
A test case has been added in area-large-dataView.html demonstrating the new button positioning functionality.
## Others
### Merging options
- [ ] Please squash the commits into a single one when merging.
### Other information
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2149561009
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +378,12 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonPosition = model.get('buttonPosition') || {};
+ buttonContainer.style.cssText = 'position:absolute;top:' + buttonPosition.top
+ + ';left:' + buttonPosition.left
+ + ';right:' + buttonPosition.right
+ + ';bottom:' + buttonPosition.bottom
+ + ';';
Review Comment:
@Ovilia I have applied your suggestion https://github.com/apache/echarts/pull/20969/commits/4677f1e8a817e1f8fee23c5e854b61821742701e
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "Ovilia (via GitHub)" <gi...@apache.org>.
Ovilia commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2148986605
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +378,12 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonPosition = model.get('buttonPosition') || {};
+ buttonContainer.style.cssText = 'position:absolute;top:' + buttonPosition.top
+ + ';left:' + buttonPosition.left
+ + ';right:' + buttonPosition.right
+ + ';bottom:' + buttonPosition.bottom
+ + ';';
Review Comment:
Most of the `top/left/right/bottom` options uses `number` type for pixel values, and most of them support percentage position relative to the container. I'd suggest using `buttonExtraCssText` instead of `buttonPosition`, similar to [tooltip.extraCssText](https://echarts.apache.org/en/option.html#tooltip.extraCssText). In this way, we can provide more flexibility to developers and it's easier to implement.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2151472809
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +377,8 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonExtraCssText = model.get('buttonExtraCssText') || '';
+ buttonContainer.style.cssText = 'position:absolute;' + buttonExtraCssText;
Review Comment:
Do you suggest other naming than ?
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "Ovilia (via GitHub)" <gi...@apache.org>.
Ovilia commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2156356628
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +377,8 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonExtraCssText = model.get('buttonExtraCssText') || '';
+ buttonContainer.style.cssText = 'position:absolute;' + buttonExtraCssText;
Review Comment:
How about `buttonContainerExtraCssText`?
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2876479813
Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
The pull request is marked to be `PR: author is committer` because you are a committer of this project.
Document changes are required in this PR. Please also make a PR to [apache/echarts-doc](https://github.com/apache/echarts-doc) for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the `PR: awaiting doc` label.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2876864679
> The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20969@e88138d
It looks like this auto build doesn't actually build what I have in PR, instead something else.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2145437394
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +378,11 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ buttonContainer.style.cssText = 'position:absolute;top:' + model.get('buttonPosition').top
+ + ';left:' + model.get('buttonPosition').left
+ + ';right:' + model.get('buttonPosition').right
+ + ';bottom:' + model.get('buttonPosition').bottom
+ + ';';
Review Comment:
Resolved in https://github.com/apache/echarts/pull/20969/commits/213b080e711720740e151074c183cbce2801df2a
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-4238155421
Any chance to merge this ?
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2876509657
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20969@e88138d
<!-- ECHARTS_PR_PREVIEW -->
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2145436127
##########
test/area-large-dataView.html:
##########
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
Review Comment:
Resolved in https://github.com/apache/echarts/pull/20969/commits/213b080e711720740e151074c183cbce2801df2a
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "Ovilia (via GitHub)" <gi...@apache.org>.
Ovilia commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2142038553
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +378,11 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ buttonContainer.style.cssText = 'position:absolute;top:' + model.get('buttonPosition').top
+ + ';left:' + model.get('buttonPosition').left
+ + ';right:' + model.get('buttonPosition').right
+ + ';bottom:' + model.get('buttonPosition').bottom
+ + ';';
Review Comment:
It's better to save `model.get('buttonPosition')` and add default values when not defined.
```js
const buttonPosition = model.get('buttonPosition') || {};
```
Please also fix the indent to be smaller.
##########
test/area-large-dataView.html:
##########
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
Review Comment:
It doesn't seem necessary to add this new file. You make change the option in the `dataview.html`.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2151099583
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +377,8 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonExtraCssText = model.get('buttonExtraCssText') || '';
+ buttonContainer.style.cssText = 'position:absolute;' + buttonExtraCssText;
Review Comment:
`buttonExtraCssText` looks like it is for a single button rather than the button container, and can be misleading.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "Ovilia (via GitHub)" <gi...@apache.org>.
Ovilia commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2966368660
You need to clone zrender and use `npm link` to use it since the code in master branch of ECharts requires some updates that are not released on zrender npm:
```
git clone git@github.com:ecomfe/zrender.git
cd zrender
npm i
npm link
# cd to echarts dir
npm link zrender
# run `npm run lint` to check it works
```
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2160381011
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +377,8 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonExtraCssText = model.get('buttonExtraCssText') || '';
+ buttonContainer.style.cssText = 'position:absolute;' + buttonExtraCssText;
Review Comment:
@plainheart @Ovilia I have renamed it to suggested `buttonContainerExtraCssText`.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on code in PR #20969:
URL: https://github.com/apache/echarts/pull/20969#discussion_r2266194924
##########
src/component/toolbox/feature/DataView.ts:
##########
@@ -375,7 +377,8 @@ class DataView extends ToolboxFeature<ToolboxDataViewFeatureOption> {
const blockMetaList = result.meta;
const buttonContainer = document.createElement('div');
- buttonContainer.style.cssText = 'position:absolute;bottom:5px;left:0;right:0';
+ const buttonExtraCssText = model.get('buttonExtraCssText') || '';
+ buttonContainer.style.cssText = 'position:absolute;' + buttonExtraCssText;
Review Comment:
Any progress on this one ? :)
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2966208240
@Ovilia Thanks for review. I have made my changes but I have problem with commit. I could try to figure out what is all about but maybe I'm just missing something. I have pull changes from upstream master to my branch before that commit. Here is what I'm getting now:
```
> echarts@5.6.0 lint
> npx eslint --cache --cache-location node_modules/.cache/eslint src/**/*.ts ssr/client/src/**/*.ts extension-src/**/*.ts
> echarts@5.6.0 checktype
> tsc --noEmit
[96msrc/component/tooltip/TooltipHTMLContent.ts[0m:[93m22[0m:[93m31[0m - [91merror[0m[90m TS2305: [0mModule '"zrender/src/core/dom"' has no exported member 'transformLocalCoordClear'.
[7m22[0m import { transformLocalCoord, transformLocalCoordClear } from 'zrender/src/core/dom';
[7m [0m [91m ~~~~~~~~~~~~~~~~~~~~~~~~[0m
Found 1 error.
husky - pre-commit hook exited with code 2 (error)
```
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] add button positioning capability to DataView component [echarts]
Posted by "piotrzarzycki21 (via GitHub)" <gi...@apache.org>.
piotrzarzycki21 commented on PR #20969:
URL: https://github.com/apache/echarts/pull/20969#issuecomment-2970859614
> You need to clone zrender and use `npm link` to use it since the code in master branch of ECharts requires some updates that are not released on zrender npm:
>
> ```
> git clone git@github.com:ecomfe/zrender.git
> cd zrender
> npm i
> npm link
> # cd to echarts dir
> npm link zrender
> # run `npm run lint` to check it works
> ```
Thanks @Ovilia I have pushed changes which address your comments.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org