Skip to main content

QueryBuilder

<QueryBuilder /> is used to build interactive analytics query builders. It abstracts state management and API calls to Cube Backend. It uses scoped slot props technique.

Props

Slots

Default Slot

Slot Props
  • resultSet: A resultSet is an object containing data obtained from the query. ResultSet object provides a convenient interface for data manipulation.

Empty Slot

This slot functions as an empty/loading state; when the query is loading or empty, you can show something in the meantime.

Error Slot

This slot will be rendered if any error happens while the query is loading or rendering.
Slot Props
  • error: the error.
  • sqlQuery: the attempted query.

Builder Slot

  • measures, dimensions, segments, timeDimensions, filters - arrays containing the selected query builder members.
  • availableMeasures, availableDimensions, availableTimeDimensions, availableSegments - arrays containing available members to select. They are loaded via API from Cube Backend.
  • addMeasures, addDimensions, addSegments, addTimeDimensions - functions to control the adding of new members to query builder.
  • removeMeasures, removeDimensions, removeSegments, removeTimeDimensions - functions to control the removing of members to query builder.
  • setMeasures, setDimensions, setSegments, setTimeDimensions - functions to control the setting of members to query builder.
  • updateMeasures, updateDimensions, updateSegments, updateTimeDimensions - functions to control the updating of members to query builder.
  • chartType - string containing currently selected chart type.
  • updateChartType - function-setter for chart type.
  • isQueryPresent - bool indicating whether is query ready to be displayed or not.
  • query - current query, based on selected members.
  • setLimit, removeLimit - functions to control the number of results returned.
  • setOffset, removeOffset - functions to control the number of rows skipped before results returned. Use with limit to control pagination.

Example

Open in CodeSandbox

QueryRenderer

<QueryRenderer /> Vue component takes a query, fetches the given query, and uses the slot scoped props to render the resulting data.

Props

Slots

Default Slot

Slot Props
  • resultSet: A resultSet is an object containing data obtained from the query. ResultSet object provides a convenient interface for data manipulation.

Empty Slot

This slot functions as an empty/loading state; when the query is loading or empty, you can show something in the meantime.

Error Slot

This slot will be rendered if any error happens while the query is loading or rendering.
Slot Props
  • error: the error.
  • sqlQuery: the attempted query.

Example

Types

ChartType

ChartType: “line” | “bar” | “table” | “area” | “number” | “pie”

QueryBuilderState

VizState