Chart
The Chart module provides functionality to generate different types of charts based on SQL queries and other parameters.
Overview
The Chart module allows users to generate charts using different specifications like Metabase and Superset. It handles requests to generate charts and responses containing chart specifications.
Classes and Enums
Chart
The main class for interacting with the Chart module.
Constructor
public Chart(WaiiHttpClient httpClient)
httpClient
: An instance ofWaiiHttpClient
to handle HTTP requests.
Methods
public ChartGenerationResponse generate(ChartGenerationRequest params) throws IOException
params
: An instance ofChartGenerationRequest
containing the parameters for generating a chart.- Returns: An instance of
ChartGenerationResponse
containing the generated chart specifications.
ChartType
An enum representing the types of charts that can be generated.
METABASE("metabase")
SUPERSET("superset")
public enum ChartType {
METABASE("metabase"),
SUPERSET("superset");
private final String value;
ChartType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return value;
}
}
ChartSpec
An abstract class representing the specifications for a chart.
Fields
protected ChartType plotType
: The type of chart to be generated.
Methods
public ChartType getPlotType()
: Gets the type of chart.public void setPlotType(ChartType plotType)
: Sets the type of chart.
SuperSetChartSpec
A class representing the specifications for a Superset chart. Extends ChartSpec
.
Fields
private List<String> metrics
: The metrics to be displayed in the chart.private List<String> dimensions
: The dimensions to be displayed in the chart.private String chartName
: The name of the chart.private String colorHex
: The color of the chart in hexadecimal format.private String xAxis
: The label for the x-axis.private String yAxis
: The label for the y-axis.private String gridStyle
: The style of the grid.private Boolean stacked
: Whether the chart is stacked.private Integer width
: The width of the chart.private Integer height
: The height of the chart.
Methods
- Getters and setters for all fields.
MetabaseChartSpec
A class representing the specifications for a Metabase chart. Extends ChartSpec
.
Fields
private String metric
: The metric to be displayed in the chart.private String dimension
: The dimension to be displayed in the chart.private String name
: The name of the chart.private String colorHex
: The color of the chart in hexadecimal format.
Methods
- Getters and setters for all fields.
ChartTweak
A class representing a tweak made to the chart.
Fields
private String ask
: The question or request made for the tweak.private ChartSpec chartSpec
: The specifications of the chart after the tweak.
Methods
- Getters and setters for all fields.
public String toString()
: Returns a string representation of the tweak.
ChartGenerationRequest
A class representing the request to generate a chart.
Fields
private String sql
: The SQL query for generating the chart.private String ask
: The question or request made for the chart.private List<Map<String, Object>> dataframeRows
: The rows of the data frame for the chart.private List<Column> dataframeCols
: The columns of the data frame for the chart.private ChartType chartType
: The type of chart to be generated.private String parentUuid
: The UUID of the parent chart, if any.private List<ChartTweak> tweakHistory
: The history of tweaks made to the chart.
Methods
- Getters and setters for all fields.
ChartGenerationResponse
A class representing the response after generating a chart.
Fields
private String uuid
: The UUID of the generated chart.private Long timestamp
: The timestamp when the chart was generated.private ChartSpec chartSpec
: The specifications of the generated chart.
Methods
- Getters and setters for all fields.