Skip to content
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

feat(tooltip): support css #5563

Merged
merged 1 commit into from
Sep 19, 2023
Merged

feat(tooltip): support css #5563

merged 1 commit into from
Sep 19, 2023

Conversation

pearmini
Copy link
Member

Tooltip CSS

close: #5545

案例

import { Chart } from "@antv/g2";

const chart = new Chart({ container: "container" });

chart.options({
  type: "interval",
  data: {
    type: "fetch",
    value:
      "https://gw.alipayobjects.com/os/bmw-prod/f129b517-158d-41a9-83a3-3294d639b39e.csv",
    format: "csv",
  },
  encode: { x: "state", y: "population", color: "age" },
  transform: [
    { type: "sortX", by: "y", reverse: true, slice: 6 },
    { type: "dodgeX" },
  ],
  scale: { y: { nice: true } },
  axis: { y: { labelFormatter: "~s" } },
  interaction: {
    tooltip: {
      shared: true,
      css: {
        ".g2-tooltip": {
          background: "#eee",
          "border-radius": " 0.25em !important",
        },
        ".g2-tooltip-title": {
          "font-size": "20px",
          "font-weight": "bold",
          "padding-bottom": "0.25em",
        },
        ".g2-tooltip-list-item": {
          background: "#ccc",
          padding: "0.25em",
          margin: "0.25em",
          "border-radius": "0.25em",
        },
        ".g2-tooltip-list-item-name-label": {
          "font-weight": "bold",
          "font-size": "16px",
        },
        "g2-tooltip-list-item-marker": {
          "border-radius": "0.25em",
          width: "15px",
          height: "15px",
        },
        ".g2-tooltip-list-item-value": {
          "font-weight": "bold",
          "font-size": "16px",
        },
      },
    },
  },
});

chart.render();

TODO

  • code
  • test
  • docs

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6230569071

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 88.478%

Totals Coverage Status
Change from base Build 6218798208: -0.004%
Covered Lines: 9967
Relevant Lines: 10901

💛 - Coveralls

@pearmini pearmini merged commit 8a10429 into v5 Sep 19, 2023
2 checks passed
@pearmini pearmini deleted the feat/tooltip branch September 19, 2023 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

G2 可以通过 interaction.tooltip.style 去设置 tooltip 的 css 样式
3 participants