使用 Flexbox 时,Apex 图表无法正确调整大小

Mad*_*Boy 3 html javascript css apexcharts

最近,我将 Floats 更改为 FlexBox 以便更轻松地处理面板(如我在其他问题中所建议的那样)。虽然大多数事情都按我的预期工作,但更改后我遇到了 Apex 图表的问题。

完整代码在这里:https : //github.com/EvotecIT/PSWriteHTML/blob/master/Examples/Example12-Charts/Example12.html

这是加载时的外观。您会注意到,在第 1 行和第 2 行图表中,即使它们所在的面板已就位,并且它也适用于顶行,但它们越界。

在此处输入图片说明

如果我调整大小(如 1 毫米),它将开始正常工作。

在此处输入图片说明

知道可能是什么问题吗?

在顶点图表 CSS 中,它有不使用溢出的注释(我尝试过但它没有做任何事情)但说实话,我什至有一次忘记附加该 CSS 并且没有任何更改(就像一切都是由 JS 完成的。

        .apexcharts-canvas {
            position: relative;
            user-select: none;
            /* cannot give overflow: hidden as it will crop tooltips which overflow outside chart area */
        }

        /* scrollbar is not visible by default for the legend, hence forcing the visibility */
Run Code Online (Sandbox Code Playgroud)

请记住,当涉及到 JS/CSS/HTML 时,我完全是个菜鸟,所以请原谅我的语言。

jun*_*ipa 8

您需要将所有脚本移到最后,而不是注入 HTML 以允许 SVG 文档解析器正确获取元素的大小。

工作Codepen 示例

var options = {
  "chart": {
    "height": 350,
    "type": "line",
    "toolbar": {
      "show": true,
      "tools": {
        "download": true,
        "selection": true,
        "zoom": true,
        "zoomin": true,
        "zoomout": true,
        "pan": true,
        "reset": true
      },
      "autoSelected": "zoom"
    }
  },
  "plotOptions": {
    "bar": {
      "horizontal": true
    }
  },
  "dataLabels": {
    "enabled": true,
    "offsetX": -6,
    "style": {
      "fontSize": "12px",
      "colors": [
        null
      ]
    }
  },
  "series": [{
      "name": "People count",
      "data": [
        400,
        430,
        448
      ]
    },
    {
      "name": "People death",
      "data": [
        450,
        0,
        200
      ]
    }
  ],
  "xaxis": {
    "type": "category",
    "categories": [
      "2015",
      "2016",
      "2017"
    ]
  },
  "stroke": {
    "show": true,
    "curve": "straight",
    "width": 2,
    "colors": [
      "#0000ff",
      "#008000"
    ]
  },
  "legend": {
    "position": "right",
    "offsetY": 100,
    "height": 230
  },
  "title": {

  }
}

var chart = new ApexCharts(document.querySelector('#ChartID-2rhiatbe'),
  options
);
chart.render();
Run Code Online (Sandbox Code Playgroud)