Annotated Chart

This chart allows users to interactively change their data across a timeline. In the frontend, users can click inside the chart to display a modal with options to add a point or two to the timeline, as well as add an annotation for that point.

The chart requires a separate dataset for each series to plot, and it needs the y-field-name specified for each of them. All datasets must have the same name for the x-field and for the annotations field. The x-field values must be of type Date or convertible to it, the y-field must be integers, and the annotation field values must be strings.

The modal that appears includes a slider to select the value that the user wants to add. This can be configured with the slider_config parameter, where the max value can be defined, and also the defaultValue. Labels can be added to the slider values using the slider_marks parameter.

The Method To Use

The method is s.plt.annotated_chart()

It must contain the following input variables:

data: Union[List[DataFrame], List[List[Dict]]]
order: int
x: str 
y: List[str] 

Accepts the following input variables as optional:

annotations: str
rows_size: Optional[int]
cols_size: Optional[int]
padding: Optional[str]
title: Optional[str]
y_axis_name: Optional[str]
slider_config: Optional[Dict]
slider_marks: Optional[Dict]

Examples

An example on how to use it would be:

Annotated chart with two datasets

When clicking in the chart the modal appears like so:

Annotation modal

It lets the user select a date range and the value of the point. Also it lets the user write an annotation in the bottom text field.

If we use the following values:

Form ready to send

The result in the chart is:

Annotation added

Last updated

Was this helpful?