Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotations #81

Closed
3 of 6 tasks
markov00 opened this issue Feb 28, 2019 · 4 comments
Closed
3 of 6 tasks

Add annotations #81

markov00 opened this issue Feb 28, 2019 · 4 comments
Assignees
Labels
:chart Chart element related issue enhancement New feature or request

Comments

@markov00
Copy link
Member

markov00 commented Feb 28, 2019

Is your feature request related to a problem? Please describe.
We need to display annotations on charts like the current time marker, partial-data areas or other general annotations.

Describe the solution you'd like
Add the possibility to include vertical or horizontal lines or rectangles on the chart, specifying the base x or y value where the line will lie.

This can be split into 3 different tasks:

Describe alternatives you've considered
n/a

Additional context
n/a

Kibana Cross Issues
Add any Kibana related issues/feature requests here.

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
@markov00 markov00 added the enhancement New feature or request label Feb 28, 2019
@markov00 markov00 changed the title [chart-elements] Add annotation lines/rects [chart] Add annotation lines/rects Feb 28, 2019
This was referenced Feb 28, 2019
@markov00 markov00 added this to the 7.1 milestone Feb 28, 2019
@markov00 markov00 added the :chart Chart element related issue label Feb 28, 2019
@markov00 markov00 changed the title [chart] Add annotation lines/rects Add annotation lines/rects Feb 28, 2019
@markov00
Copy link
Member Author

markov00 commented Mar 7, 2019

As a note, also the brush tool can be managed as a an annotation on the chart. We can split the events handling from the rendering part.

@emmacunningham
Copy link
Contributor

Just wanted to get some feedback about how the user will configure annotations. I propose that we add a new spec Annotations that the user can use to define their annotations. When we read in the spec, we can pass the values into the chart renderer and the rendered Annotation layer will draw using the values provided. This would allow users to define both computed annotations (we can expose helpers to make it easy for the user to define things like "draw a line in the time series graph for every response_code===500") as well as more simple custom annotation ("draw a line at 200ms to show queries that are taking too long"). That is, while the user will be able to define annotations that are directly dependent on the data in the chart, they will also be able to define annotations that are independent of the data in the chart.

Here's a rough proposal of what the annotation configs might look like:

    const lineAnnotation = {
      type: 'x',
      position: 0,
      style: {
        color: 'black',
        strokeWidth: 2,
        // and more
      },
      marker: 'star',
      hoverText: 'this is some text', // this could be a component that the user defines instead of just text
    };

    const textAnnotation = {
      text: 'show this text',
      style: {
        color: 'black',
        fontSize: 23,
        // and more
      },
      origin: {
        x: 0,
        y: 0,
      },
    };

    const rectAnnotation = {
      position: {
        x: 0,
        y: 0,
        height: 20,
        width: 20,
      },
      style: {
        color: 'black',
        strokeWidth: 2,
        // and more
      },
    };

And then when defining the chart, you would add:

<Annotations line={[lineAnnotation]} text={[textAnnotation]} rect={[rectAnnotation]} />

@markov00
Copy link
Member Author

@emmacunningham I think you are on the right track. I like the idea of helpers for data, specially because I maybe want to have an annotation on a specific series in a clustered bar chart and I know the X value, but not the position of the series on the cluster.
So the position value is a value on the data domain of the series right? like a timestamp. the width can be a bit more generic, like number | string | Array<number|string> because we can have also ordinal scales on x axis.

I see few other possibilities on the data structure:

  1. we can have a single Component for each different type of annotation, like LineAnnotations with a prop for the annotation array and a global style, and in case each annotation can include their overriding style like interface LineAnnotation { ... style?: Style }
  2. we can have a the <Annotations /> object with a globalStyles prop like:
interface GlobalStyles {
  line?: LineStyles;
  rect?: RectStyles; 
  text?: RectStyles;
}

we can also move the hoverText component out from the annotation object and have a global HoverTextComponent that takes as props an object and it knows how to render it something like:

    const lineAnnotation = {
      type: 'x',
      position: 0,
      marker: 'star',
      datum: { title: 'title', desc: 'desc'}
    };

   ...
   <Annotations
      lines={[lineAnnotation]}
      lineStyles={{
        color: 'black',
        strokeWidth: 2,
      }}
      hoverComponent={({title, desc}) => <div>{title} <br/>{desc}</div>}
    />

@markov00 markov00 changed the title Add annotation lines/rects Add annotations Apr 16, 2019
@markov00 markov00 modified the milestones: Kibana 7.2, Kibana 7.3 May 22, 2019
@markov00
Copy link
Member Author

Closing this keeping only the remaining #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:chart Chart element related issue enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants