Skip to content

Add configuration validation #85

Open

Description

Is your feature request related to a problem? Please describe.
Ensure a correct chart configuration for the developer

Describe the solution you'd like
Add a warning message on console if the chart doesn't respect a set of basic rules like:

  • avoid adding axes that are not related to configured series
  • avoid mixing series with different scale types
  • don't add a piechart together with a barseries
  • invalid accessors (for example, xAccessor={'foo'} when the data has no foo fields)

Prevent chart from not showing when config is bad, such as...

import React from 'react';

import { Chart, LineSeries, ScaleType, Position, Settings, Axis } from '../src';
import { SeededDataGenerator } from '../src/mocks/utils';

export class Playground extends React.Component<{}, { isSunburstShown: boolean }> {
  render() {
    const dg = new SeededDataGenerator();
    const data = dg.generateGroupedSeries(10, 2).map((item) => ({
      ...item,
      y1: item.y + 100,
    }));

    return (
      <>
        <div className="chart">
          <Chart>
            <Settings showLegend />
            <Axis id="y1" groupId="g1" position={Position.Left} title={'y1'} />
            <Axis id="y2" groupId="g2" position={Position.Left} title={'y2'} />
            <Axis id="x" position={Position.Bottom} title={'x'} />
            <LineSeries
              id={'aaa'}
              xScaleType={ScaleType.Linear}
              xAccessor={'x'}
              yAccessors={['y', 'y1']}
              splitSeriesAccessors={['g']}
              data={data}
            />
          </Chart>
        </div>
      </>
    );
  }
}

Describe alternatives you've considered
n/a

Additional context
n/a

Kibana Cross Issues
n/a
Checklist

  • this request is checked against already exist requests
  • every related Kibana issue is listed under Kibana Cross Issues list
  • kibana cross issue tag is associated to the issue if any kibana cross issue is present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    :specsChart specifications related issueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions