How to use the @elastic/charts.ScaleType.Ordinal function in @elastic/charts

To help you get started, we’ve selected a few @elastic/charts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / x-pack / legacy / plugins / lens / public / xy_visualization_plugin / to_expression.ts View on Github external
return defaultScale;
  }

  // use scale information if available
  if (metadata.scale === 'ordinal') {
    return ScaleType.Ordinal;
  }
  if (metadata.scale === 'interval' || metadata.scale === 'ratio') {
    return metadata.dataType === 'date' ? ScaleType.Time : ScaleType.Linear;
  }

  // fall back to data type if necessary
  switch (metadata.dataType) {
    case 'boolean':
    case 'string':
      return ScaleType.Ordinal;
    case 'date':
      return ScaleType.Time;
    default:
      return ScaleType.Linear;
  }
}
github elastic / kibana / x-pack / legacy / plugins / lens / public / xy_visualization_plugin / to_expression.ts View on Github external
export function getScaleType(metadata: OperationMetadata | null, defaultScale: ScaleType) {
  if (!metadata) {
    return defaultScale;
  }

  // use scale information if available
  if (metadata.scale === 'ordinal') {
    return ScaleType.Ordinal;
  }
  if (metadata.scale === 'interval' || metadata.scale === 'ratio') {
    return metadata.dataType === 'date' ? ScaleType.Time : ScaleType.Linear;
  }

  // fall back to data type if necessary
  switch (metadata.dataType) {
    case 'boolean':
    case 'string':
      return ScaleType.Ordinal;
    case 'date':
      return ScaleType.Time;
    default:
      return ScaleType.Linear;
  }
}
github elastic / kibana / x-pack / legacy / plugins / lens / public / xy_visualization_plugin / to_expression.ts View on Github external
);

          return {
            type: 'expression',
            chain: [
              {
                type: 'function',
                function: 'lens_xy_layer',
                arguments: {
                  layerId: [layer.layerId],

                  hide: [Boolean(layer.hide)],

                  xAccessor: [layer.xAccessor],
                  yScaleType: [
                    getScaleType(metadata[layer.layerId][layer.accessors[0]], ScaleType.Ordinal),
                  ],
                  xScaleType: [
                    getScaleType(metadata[layer.layerId][layer.xAccessor], ScaleType.Linear),
                  ],
                  isHistogram: [isHistogramDimension],
                  splitAccessor: [layer.splitAccessor],
                  seriesType: [layer.seriesType],
                  accessors: layer.accessors,
                  columnToLabel: [JSON.stringify(columnToLabel)],
                },
              },
            ],
          };
        }),
      },
github elastic / kibana / x-pack / legacy / plugins / siem / public / components / stat_items / index.tsx View on Github external
export const barchartConfigs = (config?: { onElementClick?: ElementClickListener }) => ({
  series: {
    xScaleType: ScaleType.Ordinal,
    yScaleType: ScaleType.Linear,
    stackAccessors: ['y0'],
  },
  axis: {
    xTickFormatter: numberFormatter,
  },
  settings: {
    onElementClick: getOr(() => {}, 'onElementClick', config),
    rotation: statItemBarchartRotation,
  },
  customHeight: statItemChartCustomHeight,
});