import { a as area, b as areaLineRange, c as areaSpline, d as areaSplineRange, e as areaStep, f as bar, g as bubble, l as line, s as scatter, h as spline, i as step, j as bb } from "./billboard-40998135.es.js";
import Vue, { defineComponent } from "vue";
import { U as UnitConverter, d as TimeseriesTooltip, A as AlarmCircle, I as Icon, L as Loader, n as normalizeComponent } from "./index-d387159c.es.js";
import moment from "moment";
import "v-tooltip";
import "@cldcvr/flow-aws-icon";
import "@cldcvr/flow-gcp-icon";
import "@cldcvr/flow-product-icon";
import "@cldcvr/flow-system-icon";
import "lodash-es";
import "vee-validate";
const SERIES_TYPES = {
  area: area(),
  areaLineRange: areaLineRange(),
  areaSpline: areaSpline(),
  areaSplineRange: areaSplineRange(),
  areaStep: areaStep(),
  bar: bar(),
  bubble: bubble(),
  line: line(),
  scatter: scatter(),
  spline: spline(),
  step: step()
};
var TimeseriesGetters = {
  getDeviationIconState(devType) {
    if (!this.enableDeviationColor) {
      return "default";
    } else if (devType === "negative" && this.invertDeviationColor || devType === "positive" && !this.invertDeviationColor) {
      return "success";
    } else {
      return "error";
    }
  },
  getXTickCount() {
    const width = this.getSize().width;
    const tickLabelWidth = 80;
    let count = (width / tickLabelWidth).toFixed(0);
    if (count < 2) {
      count = 2;
    }
    return count;
  },
  getYTickCount() {
    const height = this.getSize().height;
    const tickLabelheight = 30;
    let count = (height / tickLabelheight).toFixed(0);
    if (count < 2) {
      count = 2;
    }
    return count;
  },
  getTickValues() {
    const tickValues = [];
    if (this.chart) {
      const seriesNames = Object.keys(this.chart.x() ? this.chart.x() : {});
      if (seriesNames.length > 0) {
        const xValues = this.chart.x()[seriesNames[0]];
        const minX = xValues[0].getTime();
        const maxX = xValues[xValues.length - 1].getTime();
        const firstTick = moment(minX).add(2, "minute");
        const lastTick = moment(maxX).subtract(2, "minute");
        const tickInterval = 5;
        if (this.tickInterval == 0) {
          this.tickInterval = tickInterval;
        }
        if (+firstTick.format("x") > this.tickGreaterThan) {
          tickValues.push(+firstTick.format("x"));
        }
        while (lastTick.diff(firstTick, "minute") >= this.tickInterval) {
          const tValue = +firstTick.add(this.tickInterval, "minute").format("x");
          if (tValue > this.tickGreaterThan) {
            tickValues.push(tValue);
          }
        }
      }
    }
    return tickValues;
  },
  getSize() {
    if (this.$refs.chartdom) {
      return {
        width: this.$refs.chartdom.offsetWidth,
        height: this.empty ? this.$refs.chartdom.offsetHeight : this.$refs.chartdom.offsetHeight - 60
      };
    } else {
      return {
        width: 100,
        height: 100
      };
    }
  },
  getXMaxCulling() {
    const minTicks = 5;
    const maxTcks = 13;
    let ticksCanPlot = +(this.getSize().width / 100).toFixed(0) + 1;
    if (ticksCanPlot < minTicks) {
      ticksCanPlot = minTicks;
    }
    if (ticksCanPlot > maxTcks) {
      ticksCanPlot = maxTcks;
    }
    return ticksCanPlot;
  },
  getTooltip() {
    return {
      contents: (data, defaultTitleFormat, defaultValueFormat, color) => {
        const tooltipData = {
          title: null,
          points: []
        };
        const yAxisUnit = (point) => {
          const axisName = this.series.find((sr) => sr.name === point.name).yAxisName;
          return this.yAxisUnits[axisName ? axisName : "y"];
        };
        const yAxisName = (point) => {
          const axisName = this.series.find((sr) => sr.name === point.name).yAxisName;
          return axisName ? axisName : "y";
        };
        const label = (point) => {
          const label_ = this.series.find((sr) => sr.name === point.name).label;
          return label_ ? label_ : point.name;
        };
        data.forEach((d) => {
          tooltipData.title = d.x;
          tooltipData.points.push({
            name: label(d),
            value: UnitConverter.convertAndFormat(
              d.value,
              yAxisUnit(d),
              this.maxValues[yAxisName(d)].unit,
              {
                toFixed: 3,
                space: true,
                normalize: false
              }
            ),
            color: color(d),
            index: d.index
          });
        });
        const tooltipInstance = new this.tooltip({ data: tooltipData });
        return tooltipInstance.$mount().$el.outerHTML;
      },
      grouped: this.groupedTooltip,
      linked: this.linkedTooltip
    };
  },
  getYAxisConfig(axisName) {
    return {
      tick: {
        culling: {
          max: this.getYTickCount()
        },
        format: (value) => {
          return this.formatYLabel(value, axisName);
        }
      },
      padding: {
        bottom: 0
      }
    };
  },
  formatYLabel(value, axisName) {
    let toFixed = 2;
    if (value < 1) {
      toFixed = -Math.floor(Math.log10(value));
      if (toFixed <= 0) {
        toFixed = 2;
      }
      if (toFixed === Infinity || `${toFixed}` === "NaN") {
        toFixed = 0;
      }
      toFixed += 1;
    }
    return UnitConverter.convertAndFormat(
      value,
      this.yAxisUnits[axisName] ? this.yAxisUnits[axisName] : "COUNT._",
      this.maxValues[axisName].unit ? this.maxValues[axisName].unit : "COUNT._",
      {
        toFixed,
        space: true,
        normalize: false
      }
    );
  },
  getData() {
    const columns = [];
    const axes = {};
    const xAxisSet = /* @__PURE__ */ new Set();
    const colors = {};
    const types = {};
    if (this.series) {
      this.series.forEach((sr) => {
        const x_data_name = `${sr.name}_x`;
        const yColumn = [sr.name];
        const xColumn = [x_data_name];
        colors[sr.name] = sr.color;
        if (sr.points) {
          sr.points.forEach((point) => {
            xAxisSet.add(point.x);
            xColumn.push(point.x);
            yColumn.push(point.y);
          });
        }
        columns.push(yColumn);
        this.lastX[sr.name] = xColumn[xColumn.length - 1];
        if (sr.yAxisName) {
          axes[sr.name] = sr.yAxisName;
          if (sr.yAxisUnit) {
            this.yAxisUnits[sr.yAxisName] = sr.yAxisUnit;
          }
          if (sr.yAxisName === "y2") {
            this.showY2 = true;
          }
        } else {
          axes[sr.name] = "y";
          if (sr.yAxisUnit) {
            this.yAxisUnits.y = sr.yAxisUnit;
          }
        }
        if (sr.type) {
          types[sr.name] = SERIES_TYPES[sr.type];
        } else {
          types[sr.name] = line();
        }
      });
    }
    const xAxis = ["X_AXIS", ...xAxisSet];
    columns.push(xAxis);
    return { x: "X_AXIS", columns, colors, axes, types };
  },
  getThresholdLines() {
    const lines = [];
    if (this.series) {
      this.series.forEach((sr) => {
        if (sr.thresholdLines) {
          sr.thresholdLines.forEach((tline) => {
            lines.push({
              value: tline.value,
              text: tline.text ? this.formatThresholdLabel(
                sr.axisName ? sr.axisName : "y",
                tline.value,
                tline.text
              ) : `> ${tline.value}`,
              position: tline.position ? tline.position : "end",
              class: `flow-timeseries-${tline.type}`
            });
          });
        }
      });
    }
    return { lines };
  },
  formatThresholdLabel(axisName, value, templateText) {
    const formattedValue = this.formatYLabel(value, axisName);
    const reg = new RegExp("\\$\\{threshold\\}", "g");
    return templateText.replace(reg, formattedValue);
  },
  getEventLines() {
    const lines = [];
    if (this.eventLines) {
      this.eventLines.forEach((vline) => {
        lines.push({
          value: vline,
          class: "flow-timeseries-event-line"
        });
      });
    }
    return { lines };
  },
  getLatestValue(series) {
    if (series.points && series.points.length > 0) {
      const lastpoint = series.points[series.points.length - 1];
      if (lastpoint) {
        const yAxisName = series.yAxisName ? series.yAxisName : "y";
        const formattedValue = UnitConverter.convertAndFormat(
          lastpoint.y,
          series.yAxisUnit ? series.yAxisUnit : "COUNT._",
          this.maxValues[yAxisName].unit,
          {
            toFixed: 2,
            space: true,
            normalize: false
          }
        );
        return {
          y: +formattedValue.split(" ")[0] % 1 === 0 ? Math.trunc(+formattedValue.split(" ")[0]) : formattedValue.split(" ")[0],
          unit: formattedValue.split(" ")[1] ? formattedValue.split(" ")[1] : "#"
        };
      }
    } else {
      return { y: "--", unit: "#" };
    }
  },
  getDeviation(series) {
    if (series.points && series.points.length > 0) {
      const lastpoint = series.points[series.points.length - 1];
      const secondlastpoint = series.points[series.points.length - 2];
      const yAxisName = series.yAxisName ? series.yAxisName : "y";
      if (lastpoint && secondlastpoint) {
        let deviation = lastpoint.y - secondlastpoint.y;
        let type = "neutral";
        if (deviation > 0) {
          type = "positive";
        } else if (deviation < 0) {
          type = "negative";
          deviation = deviation * -1;
        }
        const covertedValue = UnitConverter.convertAndFormat(
          deviation,
          series.yAxisUnit ? series.yAxisUnit : "COUNT._",
          this.maxValues[yAxisName].unit,
          {
            toFixed: this.noDigitsAfterDeviationDecimal,
            space: true,
            normalize: false
          }
        );
        const deviationObj = {
          value: +covertedValue.split(" ")[0] === 0 ? "" : covertedValue.split(" ")[0],
          unit: covertedValue.split(" ")[1],
          type
        };
        return deviationObj;
      } else {
        return { value: "", type: "neutral", unit: "" };
      }
    } else {
      return { value: "", type: "neutral", unit: "" };
    }
  },
  getSeriesColor(series) {
    if (this.chart && this.type === "chart" && series.name) {
      return this.chart.color(series.name);
    } else if (this.type === "number") {
      return `${series.color} !important`;
    } else if (!series.name) {
      return "transparent !important";
    } else {
      return "var(--dashboard-font-dark)";
    }
  },
  getXminAndXmax() {
    let min, max;
    if (this.xMin) {
      min = this.xMin;
    }
    if (this.xMax) {
      max = this.xMax;
    }
    return {
      min,
      max
    };
  }
};
var billboard_min = "";
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("div", {
    staticClass: "flow-timeseries-container",
    attrs: {
      "empty": _vm.empty,
      "state": _vm.state,
      "transparent": _vm.transparent
    }
  }, [_vm.draggable ? _c("div", {
    staticClass: "flow-timeseries-draggable"
  }, [_c("Icon", {
    attrs: {
      "name": "i-arrange",
      "size": "small",
      "state": "dark",
      "effects": false,
      "type": "filled"
    }
  })], 1) : _vm._e(), _c("div", {
    staticClass: "flow-timeseries-topbar"
  }, [_c("div", {
    staticClass: "flow-timeseries-header"
  }, [_vm._v(" " + _vm._s(_vm.header) + " ")]), _c("div", {
    staticClass: "flow-timeseries-legends"
  }, _vm._l(_vm.series, function(sr, srindex) {
    return _c("div", {
      key: srindex + "_time_legend",
      staticClass: "flow-timeseries-legend",
      attrs: {
        "disabled": _vm.chart && _vm.type === "chart" ? _vm.chart.data.shown(sr.name).length === 0 : _vm.showDisabled
      },
      on: {
        "mouseout": function($event) {
          return _vm.handleLegendOut();
        },
        "mouseover": function($event) {
          return _vm.handleLegendHover(sr.name);
        },
        "click": function($event) {
          return _vm.handleLegendClick(sr.name);
        }
      }
    }, [_c("span", {
      staticClass: "flow-legend-circle",
      style: "background-color:" + _vm.getSeriesColor(sr)
    }), _c("span", {
      staticClass: "flow-legend-label text-ellipsis"
    }, [_vm._v(_vm._s(sr.label ? sr.label : sr.name))])]);
  }), 0)]), _vm.loading ? _c("Loader", {
    attrs: {
      "position": "absolute"
    }
  }) : _vm._e(), _c("div", {
    directives: [{
      name: "show",
      rawName: "v-show",
      value: _vm.type === "chart",
      expression: "type === 'chart'"
    }],
    ref: "chartdom",
    staticClass: "flow-timeseries-chart"
  }), _c("div", {
    directives: [{
      name: "show",
      rawName: "v-show",
      value: _vm.type === "number" && !_vm.loading,
      expression: "type === 'number' && !loading"
    }],
    ref: "numberdom",
    staticClass: "flow-timeseries-number",
    style: {
      fontSize: _vm.numberFontSize.bignumber + "px"
    }
  }, [_vm._l(_vm.series, function(activeSeries, idx) {
    return [_vm.activeSeriesIndex === idx ? _c("div", {
      key: activeSeries.name,
      staticClass: "flow-timeseries-number-stat",
      attrs: {
        "data-series-count": _vm.series.length,
        "set": (_vm.dev = _vm.getDeviation(activeSeries), _vm.value = _vm.getLatestValue(activeSeries))
      }
    }, [_c("div", {
      staticClass: "flow-timeseries-number-latest",
      style: {
        color: activeSeries.color
      }
    }, [_vm._v(" " + _vm._s(_vm.value.y) + " ")]), _c("div", {
      staticClass: "flow-timeseries-number-symbol",
      style: {
        color: activeSeries.color,
        fontSize: _vm.numberFontSize.symbol + "px"
      }
    }, [_vm._v(" " + _vm._s(_vm.value.unit) + " ")]), _vm.dev.value !== 0 ? _c("div", {
      staticClass: "flow-timeseries-number-deviation",
      style: {
        fontSize: _vm.numberFontSize.deviation + "px"
      }
    }, [_c("span", {
      staticClass: "flow-ts-n-d-symbol"
    }, [_vm.dev.type !== "neutral" ? _c("Icon", {
      attrs: {
        "name": "filled-arrow",
        "rotate": _vm.dev.type === "negative" ? 0 : 180,
        "size": "small",
        "type": "filled",
        "effects": false,
        "state": _vm.getDeviationIconState(_vm.dev.type)
      }
    }) : _vm._e()], 1), _vm._v(" " + _vm._s(_vm.dev.value) + " ")]) : _vm._e()]) : _vm._e(), _vm.activeSeriesIndex === idx ? _c("div", {
      key: activeSeries.name + "_label",
      staticClass: "flow-timeseries-label",
      attrs: {
        "data-series-count": _vm.series.length
      }
    }, [_vm._v(" " + _vm._s(activeSeries.name) + " ")]) : _vm._e()];
  })], 2), _vm.state === "error" || _vm.state === "warning" ? _c("AlarmCircle", {
    staticClass: "flow-timeseries-alarm-circle",
    attrs: {
      "type": _vm.state
    }
  }, [_c("Icon", {
    attrs: {
      "name": "bell-ring",
      "state": "light",
      "effects": false
    },
    on: {
      "click": function($event) {
        return _vm.handleAlarmClick($event);
      }
    }
  })], 1) : _vm._e()], 1);
};
var staticRenderFns = [];
var Timeseries_vue_vue_type_style_index_0_lang = "";
const __vue2_script = defineComponent({
  name: "Timeseries",
  components: {
    TimeseriesTooltip,
    AlarmCircle,
    Icon,
    Loader
  },
  props: {
    header: {
      type: String,
      default: "Timeseries Chart"
    },
    series: {
      type: Array,
      default: () => []
    },
    eventLines: {
      type: Array,
      default: () => []
    },
    groupedTooltip: {
      type: Boolean,
      default: true
    },
    linkedTooltip: {
      type: Boolean,
      default: true
    },
    state: {
      type: String,
      default: "default",
      validator(value) {
        return ["error", "default", "warning"].includes(value);
      }
    },
    type: {
      type: String,
      default: "chart",
      validator(value) {
        return ["chart", "number"].includes(value);
      }
    },
    invertDeviationColor: {
      type: Boolean,
      default: false
    },
    enableDeviationColor: {
      type: Boolean,
      default: false
    },
    transparent: {
      type: Boolean,
      default: false
    },
    noDataMessage: {
      type: String,
      default: "No Data"
    },
    loading: {
      type: Boolean,
      default: false
    },
    noDigitsAfterDeviationDecimal: {
      type: Number,
      default: 1
    },
    xMin: {
      type: [Number, Object],
      default: null
    },
    xMax: {
      type: [Number, Object],
      default: null
    },
    xTickValues: {
      type: Array,
      default: () => null
    },
    draggable: {
      type: Boolean,
      default: false
    },
    xTickPosition: {
      type: Object,
      default: () => {
        return { x: 0, y: 0 };
      }
    },
    connectNull: {
      type: Boolean,
      default: true
    },
    barWidthRatio: {
      type: Number,
      default: 0.3
    }
  },
  data() {
    return {
      id: "Timeseries_Chart",
      chart: null,
      lastX: {},
      tickFormat: "%I:%M",
      showY2: false,
      yAxisUnits: { y: "COUNT._", y2: "COUNT._" },
      activeSeriesIndex: 0,
      activeSeriesInterval: null,
      numberFontSize: {
        bignumber: 100,
        symbol: 30,
        deviation: 50
      },
      noOfTicksRemoved: 0,
      tickGreaterThan: 0,
      tickInterval: 0
    };
  },
  computed: {
    showDisabled() {
      return this.type === "chart";
    },
    empty() {
      if (this.series && this.series.length === 1 && !this.series[0].points) {
        return true;
      } else if (this.series && this.series.every((sr) => {
        return !(sr.points && sr.points.length > 0);
      })) {
        return true;
      } else {
        return false;
      }
    },
    maxValues() {
      const maxValue = { y: { value: 0 }, y2: { value: 0 } };
      if (this.series) {
        this.series.forEach((sr) => {
          if (sr.points) {
            const srValues = sr.points.map((p) => {
              return p.y;
            });
            const topValue = Math.max(...srValues);
            const yAxisName = sr.yAxisName ? sr.yAxisName : "y";
            if (topValue >= maxValue[yAxisName].value) {
              maxValue[yAxisName].value = topValue;
              const yUnit = sr.yAxisUnit ? sr.yAxisUnit : "COUNT._";
              maxValue[yAxisName].unit = UnitConverter.normalize(topValue, yUnit).unit;
            }
          }
        });
      }
      return maxValue;
    }
  },
  watch: {
    series: {
      handler() {
        if (this.type === "chart" && !this.loading) {
          this.updateChartOrPlot();
        }
      },
      deep: true
    },
    eventLines: {
      handler() {
        if (this.chart && this.type === "chart") {
          this.chart.xgrids(this.getEventLines().lines);
        }
      }
    },
    type: {
      handler() {
        this.init();
      }
    },
    loading: {
      handler() {
        this.init();
      }
    },
    xTickValues: {
      handler() {
        if (this.chart && this.xTickValues) {
          this.chart.config("axis.x.tick.values", this.xTickValues);
        }
      }
    },
    xMin: {
      handler() {
        if (this.chart && this.xMin) {
          this.chart.config("axis.x.min", this.xMin);
        }
      }
    },
    xMax: {
      handler() {
        if (this.chart && this.xMax) {
          this.chart.config("axis.x.max", this.xMax);
        }
      }
    }
  },
  mounted() {
    this.init();
  },
  beforeDestroy() {
    if (this.chart && this.type === "chart") {
      this.chart.destroy();
    }
    if (this.activeSeriesInterval) {
      clearInterval(this.activeSeriesInterval);
    }
  },
  beforeMount() {
    this.id = this.generateChartId();
    this.tooltip = Vue.extend(TimeseriesTooltip);
  },
  methods: {
    ...TimeseriesGetters,
    init() {
      if (this.type === "chart" && this.loading == false) {
        this.plot();
        window.addEventListener("resize", () => {
          this.autoSize();
        });
      }
      if (this.type === "number" && this.loading == false) {
        if (this.activeSeriesInterval) {
          clearInterval(this.activeSeriesInterval);
        }
        this.activeSeriesInterval = setInterval(() => {
          if (this.activeSeriesIndex < this.series.length - 1) {
            this.activeSeriesIndex++;
          } else {
            this.activeSeriesIndex = 0;
          }
        }, 3e3);
        this.$nextTick(() => {
          setTimeout(() => {
            this.calcNumberFontSize();
          }, 100);
        });
      }
    },
    autoSize() {
      this.$nextTick(() => {
        if (this.chart) {
          this.tickInterval = 0;
          const newSize = this.getSize();
          this.updateChartConfig();
          this.chart.resize({
            width: newSize.width,
            height: newSize.height
          });
        }
        this.calcNumberFontSize();
      });
    },
    calcNumberFontSize() {
      if (this.$refs.numberdom) {
        const height = this.$refs.numberdom.offsetHeight;
        const width = this.$refs.numberdom.offsetWidth;
        const clacAgainst = height < width ? height : width;
        const bignumbersize = clacAgainst / 2.5;
        this.numberFontSize.bignumber = bignumbersize;
        this.numberFontSize.symbol = bignumbersize * 0.3;
        this.numberFontSize.deviation = bignumbersize * 0.5;
      }
    },
    updateChartOrPlot() {
      if (this.chart) {
        this.updateChart();
      } else {
        this.plot();
      }
    },
    updateChart() {
      const newColumnValues = [];
      const xAxisSet = /* @__PURE__ */ new Set();
      this.series.forEach((sr) => {
        const lastX = this.lastX[sr.name];
        const newPoints = sr.points.filter((pt) => pt.x > lastX);
        const x_data_name = `${sr.name}_x`;
        const yColumn = [sr.name];
        const xColumn = [x_data_name];
        newPoints.forEach((point) => {
          xAxisSet.add(point.x);
          xColumn.push(point.x);
          yColumn.push(point.y);
          this.lastX[sr.name] = point.x;
        });
        newColumnValues.push(yColumn);
      });
      const xAxis = ["X_AXIS", ...xAxisSet];
      newColumnValues.push(xAxis);
      this.chart.flow({
        columns: newColumnValues,
        duration: 600,
        done: () => {
          this.noOfTicksRemoved += xAxis.length - 1;
          if (this.chart.x()[this.series[0].name]) {
            const currentpoints = [...this.chart.x()[this.series[0].name]];
            for (let idx = 0; idx < this.noOfTicksRemoved; idx++) {
              currentpoints.shift();
            }
            if (currentpoints[0]) {
              this.tickGreaterThan = currentpoints[0].getTime();
            }
          }
          this.updateChartConfig();
          this.chart.xgrids(this.getEventLines().lines);
        }
      });
    },
    updateChartConfig() {
      this.chart.config(
        "axis.x.tick.values",
        this.xTickValues ? this.xTickValues : this.getTickValues()
      );
      const xMinMax = this.getXminAndXmax();
      if (xMinMax.min) {
        this.chart.config("axis.x.min", xMinMax.min, true);
      }
      if (xMinMax.max) {
        this.chart.config("axis.x.max", xMinMax.max, true);
      }
      this.chart.config("axis.x.tick.culling.max", this.getXMaxCulling());
      this.chart.config("axis.y.tick.culling.max", this.getYTickCount());
      this.chart.config("axis.y2.tick.culling.max", this.getYTickCount());
      let yMax;
      this.series.forEach((sr) => {
        if (sr.yAxisName !== "y2") {
          const maxThreshold = sr.thresholdLines && sr.thresholdLines.length > 0 ? Math.max(...sr.thresholdLines.map((line2) => line2.value)) : 0;
          const maxPoint = (max, point) => {
            return max = point.y > max ? point.y : max;
          };
          const maxValue = sr.points ? sr.points.reduce(maxPoint, 0) : 0;
          const srYMax = Math.max(maxThreshold, maxValue);
          if (srYMax > yMax || yMax === void 0) {
            yMax = srYMax;
          }
        }
      });
      if (yMax && yMax !== 0) {
        this.chart.config("axis.y.max", yMax, true);
      }
      let yMin = 0;
      this.series.forEach((sr) => {
        if (sr.yAxisName !== "y2") {
          const minThreshold = sr.thresholdLines && sr.thresholdLines.length > 0 ? Math.min(...sr.thresholdLines.map((line2) => line2.value)) : 0;
          const minPoint = (min, point) => {
            return min = point.y < min ? point.y : min;
          };
          const minValue = sr.points ? sr.points.reduce(minPoint, 0) : 0;
          const srYMin = Math.min(minThreshold, minValue);
          if (srYMin < yMin || yMin === void 0) {
            yMin = srYMin;
          }
        }
      });
      if (yMin !== null) {
        this.chart.config("axis.y.min", yMin, true);
        this.chart.config("axis.y2.min", yMin, true);
      }
    },
    plot() {
      if (this.series.length > 0) {
        this.chart = bb.generate({
          data: {
            ...this.getData(),
            empty: {
              label: {
                text: this.noDataMessage
              }
            }
          },
          axis: {
            y2: {
              show: this.showY2,
              ...this.getYAxisConfig("y2")
            },
            x: {
              type: "timeseries",
              tick: {
                tooltip: true,
                centered: true,
                format: this.tickFormat,
                values: this.xTickValues ? this.xTickValues : this.getTickValues(),
                culling: {
                  max: this.getXMaxCulling()
                },
                fit: true,
                text: {
                  position: this.xTickPosition
                },
                outer: false
              },
              ...this.getXminAndXmax()
            },
            y: {
              ...this.getYAxisConfig("y")
            }
          },
          bar: {
            width: {
              ratio: this.barWidthRatio,
              max: 20
            }
          },
          line: {
            connectNull: this.connectNull
          },
          bindto: this.$refs.chartdom,
          size: this.getSize(),
          legend: {
            show: false
          },
          point: {
            show: true,
            r: 2,
            sensitivity: 1e3,
            focus: {
              expand: {
                r: 2
              }
            }
          },
          grid: {
            x: {
              show: true,
              ...this.getEventLines()
            },
            y: {
              show: true,
              ...this.getThresholdLines()
            },
            focus: {
              y: true,
              show: true,
              edge: false
            }
          },
          tooltip: {
            ...this.getTooltip()
          },
          transition: {
            duration: 0
          }
        });
        setTimeout(() => {
          this.autoSize();
        }, 100);
      }
    },
    generateChartId() {
      let id = "";
      const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
      const charsLength = chars.length;
      for (let i = 0; i < 10; i++) {
        id += chars.charAt(Math.floor(Math.random() * charsLength));
      }
      return id;
    },
    handleAlarmClick(e) {
      this.$emit("alarmclick", e);
    },
    handleLegendHover(seriesname) {
      if (this.chart && seriesname) {
        this.chart.focus(seriesname);
      }
    },
    handleLegendOut() {
      if (this.chart) {
        this.chart.revert();
      }
    },
    handleLegendClick(seriesname) {
      if (this.chart && seriesname) {
        this.chart.toggle(seriesname);
      }
    }
  }
});
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(
  __vue2_script,
  render,
  staticRenderFns,
  false,
  __vue2_injectStyles,
  null,
  null,
  null
);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var Timeseries = /* @__PURE__ */ function() {
  return __component__.exports;
}();
export { Timeseries as default };
//# sourceMappingURL=Timeseries-f5c9e832.es.js.map
