Class AbstractChartBuilder<C extends AbstractChartBuilder<C>>
- All Implemented Interfaces:
Portlet,Portlet
- Direct Known Subclasses:
BarLineChart,BoxplotChart,BubbleChart,DataTableChart,DetailedTimeSeriesChart,HeatmapChart,HistogramChart,PieChart,ScatterChart,TimeSeriesChart,TimeSeriesScatterChart,WaterfallChart,WaterfallComparisonChart
ChartBuilder, such as
ScatterChart, TimeSeriesChart, and BarLineChart. You never instantiate this class or
a concrete subclass of it directly; you get one by calling a factory method on ChartBuilder (itself
obtained via api.newChartBuilder()), for example ChartBuilder.newScatter() or
ChartBuilder.newBarLine().
Beyond the axis and series configuration each concrete chart type adds, this class provides the behavior
every chart definition shares: sizing and positioning as a Dashboard portlet (withWidth(int),
withHeight(int), withLayout(int, int) and their unit-aware overloads), informational,
warning, and error messages, click-triggered Dashboard events (onRowClick(),
onCellClick()), and populating the chart from a QueryBuilder Dashboard input
(fromQueryBuilderState(java.util.Map)).
The chart definition a concrete subclass eventually builds is what Dashboard portlets, quote headers, and other Data Analyzer areas render. The same Groovy code is also what the View Expression function generates when a user builds the equivalent chart in the Pricefx UI.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanFields inherited from class AbstractBuilder
METHOD_BUILDFields inherited from class ObjectIdentity
classId, idGenerator, instanceId, invocations, m, NONE, parentObjectIdentity -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChartBuilder(String classId, IdGenerator idGenerator, Invocations<MethodInvocation> invocations) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddInvocation(String methodName, Object... arguments) protected ChartBuilderResultfromQueryBuilderState(Map<String, Object> state) Configures aDataTableChartbased on the output of theQueryBuilderDashboard input.final Dictionary<C> Returns the builder for this chart's Dictionary, the Data Analyzer panel that controls formatting of dates, numbers, and other display labels (see the Dictionary option in the Data Analyzer UI).abstract AbstractChartOptions<C, ?> Returns this chart's Options builder.protected CgetThis()protected Stringprotected Stringprotected Stringlayout()Configures a click-triggered event fired when a user clicks a cell on this chart's Data tab (the grid view available for most Data Analyzer chart types), most commonly used with aDataTableChart.Configures a click-triggered event fired when a user clicks a row on this chart's Data tab (the grid view available for most Data Analyzer chart types), most commonly used with aDataTableChart.PortletwithDragDrop(boolean enabled) Enables or disables the drag&drop feature for portlets.PortletAdds an error message to the given portlet.PortletwithHeight(int height) Builder style method for setting the height in pixels.PortletwithHeight(int height, String unit) Builder style method for setting the height in supported units.PortletAdds an info message to the given portlet.PortletwithLabelOverride(String label) Overrides the default label of a portlet.PortletwithLayout(int width, int height) Builder style method for setting width and height in pixels.PortletwithLayout(int width, int height, String unit) Builder style method for setting width and height in specified units.PortletwithLayout(int width, int height, String wUnit, String hUnit) Builder style method for setting width and height in independently specified units, for when the width and height need different units, for example a fixed pixel height with a grid-relative width.PortletwithResizing(boolean enabled) Enables or disables the resizing feature for portlets.PortletAssigns the portlet to a specific tab in a multitab dashboard.PortletwithWarning(String code, String userMsg, String techMsg) Adds a warning message to the given portlet.PortletwithWidth(int width) Builder style method for setting the width in pixels.PortletBuilder style method for setting the width in supported units.Methods inherited from class AbstractBuilder
buildMethods inherited from class ObjectIdentity
addInvocation, addInvocationInternal, getClassId
-
Field Details
-
layout
-
queryBuilderState
-
messages
-
dragDropEnabled
protected boolean dragDropEnabled -
resizingEnabled
protected boolean resizingEnabled
-
-
Constructor Details
-
AbstractChartBuilder
protected AbstractChartBuilder(String classId, IdGenerator idGenerator, Invocations<MethodInvocation> invocations)
-
-
Method Details
-
addInvocation
- Overrides:
addInvocationin classObjectIdentity
-
getThis
-
getDictionary
Returns the builder for this chart's Dictionary, the Data Analyzer panel that controls formatting of dates, numbers, and other display labels (see the Dictionary option in the Data Analyzer UI). The Dictionary is built from a single opaque, pre-serialized string viaDictionary.buildFromOpaqueString(String), the same string the View Expression function generates when a user configures the Dictionary in the Pricefx UI; it is not meant to be hand-authored field by field.Example:
def chart = api.newChartBuilder().newScatter() chart.getDictionary().buildFromOpaqueString(dictionaryDefinition)- Returns:
- this chart's
Dictionarybuilder. Nevernull. - See Also:
-
invokeGetOptions
-
getOptions
Returns this chart's Options builder. Each concrete chart type declares its own Options subclass (for exampleScatterChart.ScatterOptions,BarLineChart.BarLineOptions) exposing the settings that apply to that chart type, such as title, subtitle, and axis label and bound overrides; the exact set of available options differs per chart type, which is why this method is declared abstract here rather than implemented once for every chart.- Returns:
- this chart's type-specific
AbstractChartOptionsinstance. Nevernull.
-
invokeAddSeries
-
invokeGetSeries
-
addAuxLine
-
onRowClick
Configures a click-triggered event fired when a user clicks a row on this chart's Data tab (the grid view available for most Data Analyzer chart types), most commonly used with aDataTableChart. CallChartEvents.OnRowClick.triggerEvent(String)on the returned builder, thenChartEvents.OnRowClick.RowClickTriggerEvent.withDimensionAsEventDataAttr(String)once per grid dimension whose value should be included in the event payload, orChartEvents.OnRowClick.RowClickTriggerEvent.withAnyDimensionAsEventDataAttr()for all of them. The triggered event is typically consumed by an embedded Dashboard to refresh another portlet with the clicked row's data.Note: this event is not offered on the Data tab of a
WaterfallChartorWaterfallComparisonChart.Example:
def table = api.newChartBuilder().newDataTable() table.onRowClick() .triggerEvent(api.dashboardWideEvent("productSelected")) .withDimensionAsEventDataAttr("ProductID")- Returns:
- a new
ChartEvents.OnRowClickbuilder for this chart. Nevernull. - See Also:
-
onCellClick
Configures a click-triggered event fired when a user clicks a cell on this chart's Data tab (the grid view available for most Data Analyzer chart types), most commonly used with aDataTableChart. CallChartEvents.OnCellClick.triggerEvent(String)on the returned builder, thenChartEvents.OnCellClick.CellClickTriggerEvent.withDimensionAsEventDataAttr(String)for the dimension(s) whose column the clicked cell must belong to (orChartEvents.OnCellClick.CellClickTriggerEvent.withAnyDimensionAsEventDataAttr()for any column). UnlikeonRowClick(), only the clicked cell's own value is included in the event payload, not the whole row. The triggered event is typically consumed by an embedded Dashboard to refresh another portlet with the clicked cell's data.Note: this event is not offered on the Data tab of a
WaterfallChartorWaterfallComparisonChart.Example:
def table = api.newChartBuilder().newDataTable() table.onCellClick() .triggerEvent(api.dashboardWideEvent("cellSelected")) .withDimensionAsEventDataAttr("ProductID")- Returns:
- a new
ChartEvents.OnCellClickbuilder for this chart. Nevernull. - See Also:
-
build
-
withWidth
Description copied from interface:PortletBuilder style method for setting the width in supported units.Example – setting the width using the 12-column system (grid):
Example – setting the width using pixels:portlet.withWidth(12, "grid")portlet.withWidth(400, "px") // == portlet.withWidth(400) -
withHeight
Description copied from interface:PortletBuilder style method for setting the height in supported units.Example – setting the height using the 12-column system (grid):
Example – setting the height using pixels:portlet.withHeight(12, "grid")portlet.withHeight(800, "px") // == portlet.withHeight(800)- Specified by:
withHeightin interfacePortlet- Parameters:
height- Specifies the height of the portlet (in unit).unit- Specifies the unit of the height (grid,px). If the unit is not specified thenpxis used as default.- Returns:
- The current portlet object of the specified size.
- See Also:
-
withLayout
Description copied from interface:PortletBuilder style method for setting width and height in specified units.Example - sets the portlet size to the specified grid size:
def matrix = api.newMatrix("column1", "column2", "column3") matrix.addRow(1, "a", "f") matrix.addRow(2, "b", "g") matrix.withLayout(3, 3, "grid") return matrix- Specified by:
withLayoutin interfacePortlet- Parameters:
width- Specifies the width of the portlet.height- Specifies the height of the portlet.unit- Specifies a unit of the layout (grid,px).- Returns:
- The current portlet object of the specified size.
- See Also:
-
withInfo
Description copied from interface:PortletAdds an info message to the given portlet. One portlet can have multiple messages. It is a different concept than yellow/red alerts.Example:
portlet.withInfo("101", "Chart data may be outdated", "Bubble Chart data is outdated, because of ...") -
withWarning
Description copied from interface:PortletAdds a warning message to the given portlet. One portlet can have multiple messages. It is a different concept than yellow/red alerts.Example:
portlet.withWarning("102", "Chart data is missing", "Bubble Chart data is missing, because of ...")- Specified by:
withWarningin interfacePortlet- Parameters:
code- Warning code allows pinpointing the place where the warning is thrown in code.userMsg- A warning message is displayed to a user in UI.techMsg- Technical message is hidden by default, only for the investigation purposes.
-
withError
Description copied from interface:PortletAdds an error message to the given portlet. One portlet can have multiple messages. It is a different concept than yellow/red alerts.Example:
portlet.withError("103", "Chart was not found", "Bubble Chart could not be found, because of ...") -
withLayout
Builder style method for setting width and height in independently specified units, for when the width and height need different units, for example a fixed pixel height with a grid-relative width. This is an extension beyondPortlet.withLayout(int, int, String), which requires the same unit for both dimensions.Note: unlike the single-unit overload, this method does not validate
width/heightagainst the 1-12 grid bounds (seePortlet.UNIT_GRID); only the unit tokens themselves are validated.Example:
chart.withLayout(6, 400, "grid", "px")- Parameters:
width- Specifies the width of the portlet (inwUnit).height- Specifies the height of the portlet (inhUnit).wUnit- Specifies the unit of the width (grid,px).hUnit- Specifies the unit of the height (grid,px).- Returns:
- this portlet instance, sized as specified
- Throws:
RuntimeException- ifwUnitorhUnitis not one of the supported units- See Also:
-
value
-
withWidth
public Portlet withWidth(int width) Description copied from interface:PortletBuilder style method for setting the width in pixels. -
withHeight
public Portlet withHeight(int height) Description copied from interface:PortletBuilder style method for setting the height in pixels.- Specified by:
withHeightin interfacePortlet- Parameters:
height- specify the height of the portlet (in pixels)- Returns:
- The current portlet object of the specified size.
- See Also:
-
withLayout
public Portlet withLayout(int width, int height) Description copied from interface:PortletBuilder style method for setting width and height in pixels.- Specified by:
withLayoutin interfacePortlet- Parameters:
width- specify the width of the portlet (in pixels)height- specify the height of the portlet (in pixels)- Returns:
- The current portlet object of the specified size.
- See Also:
-
layout
-
fromQueryBuilderState
Configures aDataTableChartbased on the output of theQueryBuilderDashboard input.
Note: So far the only supported chart type isDataTable, which will show a separate tab for each series configured in the QueryBuilder input.Example:
def qbState = input.MyQueryBuilder api.newChartBuilder() .newDataTable() .fromQueryBuilderState(qbState) .build()- Parameters:
state- PropertiesMapas returned by theQueryBuilderinput- Returns:
- self
- Since:
- 11.0 Paper Plane for DataTableChart, 12.0 Clover Club experimental for all other chart types
-
withDragDrop
public Portlet withDragDrop(boolean enabled) Description copied from interface:PortletEnables or disables the drag&drop feature for portlets. Set tofalseto disable the drag&drop option. The default state is ENABLED.Example - disables the drag&drop of the Result Matrix portlet:
def matrix = api.newMatrix("column1", "column2", "column3") matrix.addRow(1, "a", "f") matrix.addRow(2, "b", "g") matrix.withDragDrop(false) return matrix- Specified by:
withDragDropin interfacePortlet- Parameters:
enabled- on/off switch. Default =true.- Returns:
- this Portlet instance
-
withResizing
public Portlet withResizing(boolean enabled) Description copied from interface:PortletEnables or disables the resizing feature for portlets. Set tofalseto disable the resizing of the portlet. The default state is ENABLED.Example - disables the resizing option of the Result Matrix portlet:
def matrix = api.newMatrix("column1", "column2", "column3") matrix.addRow(1, "a", "f") matrix.addRow(2, "b", "g") matrix.withResizing(false) return matrix- Specified by:
withResizingin interfacePortlet- Parameters:
enabled- on/off switch. Default =true.- Returns:
- this Portlet instance
-
withTab
Description copied from interface:PortletAssigns the portlet to a specific tab in a multitab dashboard.Tabs must be defined in the Model Class (MC) definition under the
dashboardTabslist for the corresponding step.
If the tab name is not found in the MC definition, the portlet falls back to the default tab and a warning is logged to the console.Example:
return api.inputBuilderFactory().createInputMatrix("MatrixEntry") .setColumns(columns) .setColumnValueOptions(columnsValueOptions) .setValue([ [col1: "a1", col2: "b1"], [col1: "a2", col2: "b2"] ]) .setLabel("MatrixEntry") .setTab("multitab_dashboard_inputs_and_portlets") .getInput() -
withLabelOverride
Description copied from interface:PortletOverrides the default label of a portlet. This method is implemented for the subtypes of AbstractPortletDto and AbstractChartBuilder only.- Specified by:
withLabelOverridein interfacePortlet- Parameters:
label- Suggested new label- Returns:
- the current portlet instance
-