Skip to content

add button positioning capability to DataView component #20969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

piotrzarzycki21
Copy link
Member

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.

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Adds positioning capability to DataView buttons in the toolbox component.

Fixed issues

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
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • 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

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.
Copy link

echarts-bot bot commented May 13, 2025

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about 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 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.

Copy link
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20969@e88138d

@piotrzarzycki21
Copy link
Member Author

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.

@piotrzarzycki21
Copy link
Member Author

@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)

@Ovilia
Copy link
Contributor

Ovilia commented Jun 12, 2025

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

…buttonPosition

- Improved code readability by reducing excessive indentation in string concatenation
- Example file demonstrating the use of buttonPosition property for custom positioning
PR: apache#20969
@piotrzarzycki21
Copy link
Member Author

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.

+ ';left:' + buttonPosition.left
+ ';right:' + buttonPosition.right
+ ';bottom:' + buttonPosition.bottom
+ ';';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. In this way, we can provide more flexibility to developers and it's easier to implement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ovilia I have applied your suggestion 4677f1e

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buttonExtraCssText looks like it is for a single button rather than the button container, and can be misleading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest other naming than ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about buttonContainerExtraCssText?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plainheart @Ovilia I have renamed it to suggested buttonContainerExtraCssText.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants