代码之家  ›  专栏  ›  技术社区  ›  buydadip

如何自定义VictoryToolTip

  •  0
  • buydadip  · 技术社区  · 7 年前

    我已经使用 VictoryCharts 我添加了工具提示…

    <VictoryPie
        labelComponent={<VictoryTooltip cornerRadius={0} />}
        colorScale={["tomato", "orange", "gold", "cyan", "navy" ]}
        padAngle={0.5}
        innerRadius={100}
        width={400} height={400}
        style={{ 
          labels: { fontSize: 15, fill: "black"},
          data: {
            fillOpacity: 0.9, stroke: "#c43a31", strokeWidth: 3
          }
        }}
        labelRadius={90}
        data = {data_distribution}
    />
    

    工具提示如下…

    enter image description here

    我想删除箭头,使工具提示成为一个规则的矩形,并更改背景色。本质上我想定制它,但事实证明这比我预期的要难。

    我尝试创建自定义组件…

    class CustomFlyout extends Component {
      render() {
        const {x, y} = this.props;
    
        return (
          <div style={{"background": "red"}}>
            <p>x</p>
          </div>
        );
      }
    }
    

    我添加到 VictoryTooltip

    <VictoryTooltip
        cornerRadius={0}
        flyoutComponent={<CustomFlyout/>}
     />
    

    但是,这没有任何作用。我不知道如何定制工具提示。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Mujtaba Fadhil    7 年前

    您可以自定义 VictoryTooltip 像这样设置你需要的风格。

    <VictoryTooltip
        cornerRadius={0}
        pointerLength={0}
        flyoutStyle={{
            stroke: "none",
            fill: "blue"
        }}
    />
    

    this example