function getTableColumns()

in viz-lib/src/visualizations/chart/Editor/SeriesSettings.tsx [16:80]


function getTableColumns(options: any, updateSeriesOption: any, debouncedUpdateSeriesOption: any) {
  const result = [
    {
      title: "Order",
      dataIndex: "zIndex",
      render: (unused: any, item: any) => (
        <span className="series-settings-order">
          <DragHandle />
          {item.zIndex + 1}
        </span>
      ),
    },
    {
      title: "Label",
      dataIndex: "name",
      render: (unused: any, item: any) => (
        <Input
          data-test={`Chart.Series.${item.key}.Label`}
          placeholder={item.key}
          defaultValue={item.name}
          onChange={event => debouncedUpdateSeriesOption(item.key, "name", event.target.value)}
        />
      ),
    },
  ];

  if (!includes(["pie", "heatmap"], options.globalSeriesType)) {
    if (!options.swappedAxes) {
      result.push({
        title: "Y Axis",
        dataIndex: "yAxis",
        render: (unused, item) => (
          <Radio.Group
            className="series-settings-y-axis"
            value={item.yAxis === 1 ? 1 : 0}
            onChange={event => updateSeriesOption(item.key, "yAxis", event.target.value)}>
            <Radio value={0} data-test={`Chart.Series.${item.key}.UseLeftAxis`}>
              left
            </Radio>
            <Radio value={1} data-test={`Chart.Series.${item.key}.UseRightAxis`}>
              right
            </Radio>
          </Radio.Group>
        ),
      });
    }

    result.push({
      title: "Type",
      dataIndex: "type",
      render: (unused, item) => (
        <ChartTypeSelect
          data-test={`Chart.Series.${item.key}.Type`}
          dropdownMatchSelectWidth={false}
          value={item.type}
          // @ts-expect-error ts-migrate(2322) FIXME: Type 'string' is not assignable to type 'never'.
          hiddenChartTypes={["pie", "heatmap", "bubble", "box"]}
          onChange={(value: any) => updateSeriesOption(item.key, "type", value)}
        />
      ),
    });
  }

  return result;
}