{"ast":null,"code":"var __jsx = React.createElement;\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport * as chart from '~/utils/chart';\nimport React, { useCallback, useEffect } from 'react';\nimport { position, primaryColor, size } from '~/utils/style';\nimport GridLoader from 'react-spinners/GridLoader';\nimport { formatTime } from '~/utils';\nimport styled from 'styled-components';\nimport useECharts from '~/hooks/useECharts';\nimport { useTranslation } from '~/utils/i18n';\nconst Wrapper = styled.div.withConfig({\n  displayName: \"LineChart__Wrapper\",\n  componentId: \"plq350-0\"\n})([\"position:relative;> .echarts{height:100%;}> .loading{\", \" \", \" display:flex;justify-content:center;align-items:center;}\"], size('100%'), position('absolute', 0, null, null, 0));\n\nconst LineChart = ({\n  title,\n  legend,\n  data,\n  xAxis,\n  yAxis,\n  type,\n  xRange,\n  yRange,\n  tooltip,\n  loading,\n  className\n}) => {\n  const {\n    i18n\n  } = useTranslation();\n  const {\n    ref,\n    echart\n  } = useECharts({\n    loading: !!loading,\n    zoom: true\n  });\n  const xAxisFormatter = useCallback(value => type === 'time' ? formatTime(value, i18n.language, 'LTS') : value, [type, i18n.language]);\n  useEffect(() => {\n    if (false) {\n      var _echart$current;\n\n      echart === null || echart === void 0 ? void 0 : (_echart$current = echart.current) === null || _echart$current === void 0 ? void 0 : _echart$current.setOption({\n        color: chart.color,\n        title: _objectSpread({}, chart.title, {\n          text: title !== null && title !== void 0 ? title : ''\n        }),\n        tooltip: _objectSpread({}, chart.tooltip, {}, tooltip ? {\n          formatter: tooltip\n        } : {}),\n        toolbox: chart.toolbox,\n        legend: _objectSpread({}, chart.legend, {\n          data: legend !== null && legend !== void 0 ? legend : []\n        }),\n        grid: chart.grid,\n        xAxis: _objectSpread({}, chart.xAxis, {\n          name: xAxis || '',\n          type: type || 'value',\n          axisLabel: _objectSpread({}, chart.xAxis.axisLabel, {\n            formatter: xAxisFormatter\n          })\n        }, xRange || {}),\n        yAxis: _objectSpread({}, chart.yAxis, {\n          name: yAxis || ''\n        }, yRange || {}),\n        series: data === null || data === void 0 ? void 0 : data.map(item => {\n          var _item$data$length, _item$data;\n\n          return _objectSpread({}, chart.series, {\n            // show symbol if there is only one point\n            showSymbol: ((_item$data$length = item === null || item === void 0 ? void 0 : (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.length) !== null && _item$data$length !== void 0 ? _item$data$length : 0) <= 1\n          }, item);\n        })\n      }, {\n        notMerge: true\n      });\n    }\n  }, [data, title, legend, xAxis, yAxis, type, xAxisFormatter, xRange, yRange, tooltip, echart]);\n  return __jsx(Wrapper, {\n    className: className\n  }, !echart && __jsx(\"div\", {\n    className: \"loading\"\n  }, __jsx(GridLoader, {\n    color: primaryColor,\n    size: \"10px\"\n  })), __jsx(\"div\", {\n    className: \"echarts\",\n    ref: ref\n  }));\n};\n\nexport default LineChart;","map":null,"metadata":{},"sourceType":"module"}