-
Notifications
You must be signed in to change notification settings - Fork 0
Define Charts
InteractiveData provides RESTful services for visualizing data. The interface depends on the type of visualization you specify.
The specification of a visualization consists of two separate specifications. A general specification the is consistent with all visualization types plus a specific one the depends on the type of visualization you want to produce.
To specify a visualization create a new class and annotate it with the following annotation: @ChartService("api/chart")
. Multiple visualization can be wrapped inside a single chart service.
To create a new visualization create a new method inside the chart service an annotate it with the annotation @Chart
.
The basic chart specification requires a name and a data source. The remaining attributes are optional.
-
name The name of the chart service plus the name of the chart form the unique identifier of a chart. This is part of the url to access the REST service.
-
dataSource Source of the data for the visualization. More information on the data source.
-
filter (optional) List of filters. A filter is specified by a FilterDef.
-
operation (optional) List of operations. A operation is specified by a OperationDef.
Filter allow to filter out data based on specific criteria. The framework provides a list of default filters. A filter definition allows the specification of filters to apply to the visualization data.
- fieldName Name of the field the filter will apply on.
- fieldClass Data type of the field the filter will apply on. Note: Some filters do not support every data type. See the documentation of the specific filter for more information.
- filter Class of the filter to apply.
- options (optional) List of default options. See the filter documentation for details of possible values.
comming soon, see JavaDoc
Example of a chart specification:
@Chart(
name = "line",
dataSource = MyDataSource.class
filter = {
@FilterDef(fieldName = "time", fieldClass = Date.class, filter = TimeFilter.class)
},
operations = {
@OperationDef(
fieldName = "time",
fieldClass = Date.class,
granularity = TimeGranularity.class,
functions = {
@FunctionDef(
fieldName = "id",
fieldClass = Long.class,
function = Count.class
)
}
)
}
)
A line charts consists of a list of axis definition. There can only be one X axis but infinite Y axis.
@LineChart(
axis = {
@Axis(
dataField = "time",
dataType = Instant.class,
type = Axis.Type.X
),
@Axis(
dataField = "id.count",
dataType = Long.class,
type = Axis.Type.Y
)
}
)
@Axis allows to specify filters and operations directly on the field. If the functions apply an field that are visualized this makes the specification more readable and easier to understand. See the @Chart documentation above on information how to specify filters and operations.
A pie chart consists of ists data (a list of values) and corresponding labels. Both are specified by the field annotation. Labels are optional.
@PieChart(
data = @Field(
dataField = "id.count",
dataType = Long.class
),
label = @Field(
dataField = "person",
dataType = Person.class
)
)
@Field allows to specify filters and operations directly on the field. If the functions apply an field that are visualized this makes the specification more readable and easier to understand. See the @Chart documentation above on information how to specify filters and operations.