TimelineHistogramBase
Base class for TimelineHistogram class.
Configs
213
Configs
213Common
Other
A Function which returns the tooltip text to display when hovering a bar. The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
context | Object | The tooltip context info |
context.datum | Object | The histogram bar being hovered info |
context.tip | Tooltip | The tooltip instance |
context.element | HTMLElement | The Element for which the Tooltip is monitoring mouse movement |
context.activeTarget | HTMLElement | The target element that triggered the show |
context.event | Event | The raw DOM event |
context.record | Model | The record which value the hovered bar displays. |
Tooltip HTML content
Record field from which the histogram data will be collected.
histogram = new TimelineHistogram({
...
series : {
s1 : {
type : 'bar'
}
},
dataModelField : 'foo',
store : new Store({
data : [
{
id : 'r1',
name : 'Record 1',
foo : [
{ s1 : 200 },
{ s1 : 150 },
{ s1 : 175 },
{ s1 : 175 }
]
},
{
id : 'r2',
name : 'Record 2',
foo : [
{ s1 : 100 },
{ s1 : 150 },
{ s1 : 175 },
{ s1 : 175 }
]
}
]
})
});
Alternatively getRecordData function can be used to build a record's histogram data dynamically.
A Function which returns a CSS class name to add to a rectangle element. The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
domConfig | DomConfig | The rectangle configuration object |
datum | Object | The datum being rendered |
index | Number | The index of the datum being rendered |
renderData | HistogramRenderData | Current render data giving access to the record, row and cell being rendered. |
CSS classes of the rectangle element
A Function which if provided should return a DOM configuration object for a bar
(a RECT element representing a single "bar"-type value).
The function is passed a default prepared DOM configuration
in an argument which then can be processed and returned.
new TimelineHistogram({
series : {
foo : {
type : 'bar',
field : 'foo'
}
},
// Let's add left & right margins to bars
getBarDOMConfig(series, domConfig) {
// margin size is 10% of the bar width
const xMargin = 0.1 * domConfig.width;
// adjust the bar x-coordinate
domConfig.x += xMargin;
// reduce the bar width respectively
domConfig.width -= 2 * xMargin;
// return the edited domConfig
return domConfig;
},
...
})
this will refer to the
Histogram instance, not this class instance.
To access the view please use this.owner in the function:
new TimelineHistogram({
getBarText(datum) {
// "this" in the method refers core Histogram instance
// get the view instance
const timelineHistogram = this.owner;
.....
},
...
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
domConfig | DomConfig | The rectangle DOM configuration object |
datum | Object | The datum being rendered |
index | Number | The index of the datum being rendered |
renderData | HistogramRenderData | Current render data giving access to the record, row and cell being rendered. |
Resulting DOM configuration object. If no value returned the bar is not displayed.
A Function which returns the text to render inside a bar.
new TimelineHistogram({
series : {
foo : {
type : 'bar',
field : 'foo'
}
},
getBarText(datum) {
// display the value in the bar
return datum.foo;
},
...
})
Please note that the function will be injected into the underlying
Histogram component that is used under the hood
to render actual charts.
So this will refer to the Histogram instance, not
this class instance.
To access the view please use this.owner in the function:
new TimelineHistogram({
getBarText(datum) {
// "this" in the method refers core Histogram instance
// get the view instance
const timelineHistogram = this.owner;
.....
},
...
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
datum | Object | The datum being rendered |
index | Number | The index of the datum being rendered |
series | HistogramSeries | The series (provided if histogram widget
singleTextForAllBars is |
renderData | HistogramRenderData | Current render data giving access to the record, row and cell being rendered. |
Text to render inside the bar
A Function which returns a DOM configuration object for text elements.
new TimelineHistogram({
series : {
foo : {
type : 'bar',
field : 'foo'
}
},
// display "foo" bar value as text
getBarText(datum) {
return datum.foo;
},
// Place text at the top of the "foo" bar
getBarTextDOMConfig(domConfig, datum, index) {
// to do that we calculate y-position in percents
domConfig.y = `${100 * (1 - datum.foo / this.topValue)}%`;
return domConfig;
},
...
})
this will refer to the Histogram instance, not
this class instance.
To access the view please use this.owner in the function:
new TimelineHistogram({
getBarTextDOMConfig(domConfig) {
// "this" in the method refers core Histogram instance
// get the view instance
const timelineHistogram = this.owner;
.....
return domConfig;
},
...
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
domConfig | DomConfig | The |
datum | Object | The datum being rendered |
index | Number | The index of the datum being rendered |
series | HistogramSeries | The series (provided if histogram widget
singleTextForAllBars is |
renderData | HistogramRenderData | Current render data giving access to the record, row and cell being rendered. |
The TEXT element DOM configuration object. If no value returned the text element is not
displayed.
A Function which returns a CSS class name to add to a path element
built for an outline type series.
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
data | Object[] | The series data |
renderData | HistogramRenderData | Current render data giving access to the record, row and cell being rendered. |
CSS class name of the path element
A Function which if provided should return a DOM configuration object for
a path element built for an outline type series.
The function accepts a default prepared DOM configuration
in an argument which then can be processed and returned.
The following parameters are passed to the function:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
domConfig | DomConfig | The |
data | Object[] | The series data |
Resulting DOM configuration object. If no value returned the path is not displayed.
A function, or name of a function which builds histogram data for the provided record.
See also dataModelField allowing to load histogram data from a record field.
| Parameter | Type | Description |
|---|---|---|
getRecordData.record | Model | Record to get histogram data for. |
aggregationContext | Object | Context object passed in case the data is being retrieved as a part of some parent record data collecting. |
Histogram data.
When set to true (default) the component reacts on time axis changes
(zooming or changing the displayed time span), clears the histogram data cache of the records
and then refreshes the view.
An instance or a configuration object of the underlying Histogram component that is used under the hood to render actual charts. In case a configuration object is provided the built class is defined with histogramWidgetClass config.
The class used for building the histogram widget
Object enumerating data series for the histogram. The object keys are treated as the series identifiers and values are objects that must contain two properties:
typeA String, either'bar'or'outline'fieldA String, the name of the property to use from the data objects in the data option.
histogram = new TimelineHistogram({
...
series : {
s1 : {
type : 'bar',
field : 's1'
},
s2 : {
type : 'outline',
field : 's2'
}
},
store : new Store({
data : [
{
id : 'r1',
name : 'Record 1',
histogramData : [
{ s1 : 200, s2 : 100 },
{ s1 : 150, s2 : 50 },
{ s1 : 175, s2 : 50 },
{ s1 : 175, s2 : 75 }
]
},
{
id : 'r2',
name : 'Record 2',
histogramData : [
{ s1 : 100, s2 : 100 },
{ s1 : 150, s2 : 125 },
{ s1 : 175, s2 : 150 },
{ s1 : 175, s2 : 75 }
]
}
]
})
});
Set to true if you want to display a tooltip when hovering an allocation bar. You can also pass a
Tooltip#configs config object.
Please use barTooltipTemplate function to customize the tooltip contents.
Content
CSS
Dates
DOM
Float & align
Layout
Masking
misc
Misc
Scheduled events
State
Time axis
Tree
Zoom
Properties
192
Properties
192Common
Class hierarchy
Other
The underlying Histogram component that is used under the hood to render actual charts.
Set to true if you want to display a tooltip when hovering an allocation bar. You can also pass a
Tooltip#configs config object.
Please use barTooltipTemplate function to customize the tooltip contents.
CSS
Dates
DOM
Infinite scroll
Layout
Misc
Scheduled events
Scrolling
Selection
State
Time axis
Tree
Widget hierarchy
Functions
166
Functions
166Other
Clears the histogram data cache for the provided record (if provided). If the record is not provided clears the cache for all records.
| Parameter | Type | Description |
|---|---|---|
record | Model | Record to clear the cache for. |
Returns entire histogram data cache if no record provided, or cached data for the provided record.
| Parameter | Type | Description |
|---|---|---|
record | Model | Record to get the cached data for. |
The provided record cached data or all the records data cache
as a Map keyed by records.
Retrieves the histogram data for the provided record.
The method first checks if there is cached data for the record and returns it if found. Otherwise it starts collecting data by calling getRecordData (if provided) or by reading it from dataModelField record field.
The method can be asynchronous depending on the provided getRecordData function.
If the function returns a Promise then the method will return a wrapping Promise in turn that will
resolve with the collected histogram data.
The method triggers histogramDataCacheSet event when a record data is ready.
| Parameter | Type | Description |
|---|---|---|
record | Model | Record to retrieve the histogram data for. |
The histogram data for the provided record or a Promise that will provide the data
when resolved.
Returns true if there is cached histogram data for the provided record.
| Parameter | Type | Description |
|---|---|---|
record | Model | Record to check the cache existence for. |
True if there is a cache for provided record.
Schedules the component rows refresh on the next animation frame. However many time it is called in one event run, it will only be scheduled to run once.
Caches the provided histogram data for the given record.
| Parameter | Type | Description |
|---|---|---|
record | Model | Record to cache data for. |
data | Object | Histogram data to cache. |
Configuration
Data
Dates
Events
Getters
Misc
Rendering
Rows
Scrolling
Selection
Widget hierarchy
Zoom
Events
64
Events
64Fires before the component stores a record's histogram data into the cache.
A listener can be used to transform the collected data dynamically before it's cached:
new TimelineHistogram({
series : {
foo : {
type : 'bar',
field : 'f1'
}
},
...
listeners : {
beforeHistogramDataCacheSet(eventData) {
// completely replace the data for a specific record
if (eventData.record.id === 123) {
eventData.data = [
{ f1 : 10 },
{ f1 : 20 },
{ f1 : 30 },
{ f1 : 40 },
{ f1 : 50 },
{ f1 : 60 }
];
}
}
}
})
// Adding a listener using the "on" method
timelineHistogramBase.on('beforeHistogramDataCacheSet', ({ source, record, data }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
data | Object | The record histogram data. |
Fires before the component renders a row.
This event is recommended to use instead of generic beforeRenderRow event since the component bails out of rendering rows for which histogram data is not ready yet (happens in case of async data collecting). The generic beforeRenderRow is triggered in such cases too while this event is triggered only when the data is ready and the row is actually about to be rendered.
Use a listener to adjust histograms rendering dynamically for individual rows:
new TimelineHistogram({
...
listeners : {
beforeRenderHistogramRow({ record, histogramConfig }) {
// display an extra line for some specific record
if (record.id == 111) {
histogramConfig.series.extraLine = {
type : 'outline',
field : 'foo'
};
}
}
}
})
// Adding a listener using the "on" method
timelineHistogramBase.on('beforeRenderHistogramRow', ({ source, record, histogramConfig, histogramWidget }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
histogramConfig | HistogramConfig | Configuration object that will be applied to |
histogramWidget | Histogram | The underlying widget that is used to render a chart. |
Fires before the component renders a histogram in a cell.
// Adding a listener using the "on" method
timelineHistogramBase.on('beforeRenderRecordHistogram', ({ source, record, histogramConfig, histogramWidget }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
histogramConfig | HistogramConfig | Configuration object that will be applied to |
histogramWidget | Histogram | The underlying widget that is used to render a chart. |
Fires after the component retrieves a record's histogram data and stores it into the cache.
Unlike similar beforeHistogramDataCacheSet event this event is triggered after the data is put into the cache.
A listener can be used to transform the collected data dynamically:
new TimelineHistogram({
series : {
bar : {
type : 'bar',
field : 'bar'
},
halfOfBar : {
type : 'outline',
field : 'half'
}
},
...
listeners : {
histogramDataCacheSet({ data }) {
// add extra entries to collected data
data.forEach(entry => {
entry.half = entry.bar / 2;
});
}
}
})
// Adding a listener using the "on" method
timelineHistogramBase.on('histogramDataCacheSet', ({ source, record, data }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
data | Object | The record histogram data. |
Event handlers
64
Event handlers
64Called before the component stores a record's histogram data into the cache.
A listener can be used to transform the collected data dynamically before it's cached:
new TimelineHistogram({
series : {
foo : {
type : 'bar',
field : 'f1'
}
},
...
listeners : {
beforeHistogramDataCacheSet(eventData) {
// completely replace the data for a specific record
if (eventData.record.id === 123) {
eventData.data = [
{ f1 : 10 },
{ f1 : 20 },
{ f1 : 30 },
{ f1 : 40 },
{ f1 : 50 },
{ f1 : 60 }
];
}
}
}
})
new TimelineHistogramBase({
onBeforeHistogramDataCacheSet({ source, record, data }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
data | Object | The record histogram data. |
Called before the component renders a row.
This event is recommended to use instead of generic beforeRenderRow event since the component bails out of rendering rows for which histogram data is not ready yet (happens in case of async data collecting). The generic beforeRenderRow is called in such cases too while this event is called only when the data is ready and the row is actually about to be rendered.
Use a listener to adjust histograms rendering dynamically for individual rows:
new TimelineHistogram({
...
listeners : {
beforeRenderHistogramRow({ record, histogramConfig }) {
// display an extra line for some specific record
if (record.id == 111) {
histogramConfig.series.extraLine = {
type : 'outline',
field : 'foo'
};
}
}
}
})
new TimelineHistogramBase({
onBeforeRenderHistogramRow({ source, record, histogramConfig, histogramWidget }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
histogramConfig | HistogramConfig | Configuration object that will be applied to |
histogramWidget | Histogram | The underlying widget that is used to render a chart. |
Called before the component renders a histogram in a cell.
new TimelineHistogramBase({
onBeforeRenderRecordHistogram({ source, record, histogramConfig, histogramWidget }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
histogramConfig | HistogramConfig | Configuration object that will be applied to |
histogramWidget | Histogram | The underlying widget that is used to render a chart. |
Called after the component retrieves a record's histogram data and stores it into the cache.
Unlike similar beforeHistogramDataCacheSet event this event is called after the data is put into the cache.
A listener can be used to transform the collected data dynamically:
new TimelineHistogram({
series : {
bar : {
type : 'bar',
field : 'bar'
},
halfOfBar : {
type : 'outline',
field : 'half'
}
},
...
listeners : {
histogramDataCacheSet({ data }) {
// add extra entries to collected data
data.forEach(entry => {
entry.half = entry.bar / 2;
});
}
}
})
new TimelineHistogramBase({
onHistogramDataCacheSet({ source, record, data }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TimelineHistogram | The component instance |
record | Model | Record the histogram data of which is ready. |
data | Object | The record histogram data. |
Typedefs
19
Typedefs
19Histogram renderer parameters.
| Parameter | Type | Description |
|---|---|---|
histogramData | Object | Histogram data |
histogramConfig | HistogramConfig | Configuration object for the histogram widget |
cellElement | HTMLElement | null | Cell element, for adding CSS classes, styling etc.
Can be |
record | Model | Record for the row |
column | TimeAxisColumn | Owning TimeAxisColumn column |
grid | TimelineHistogramBase | Owning TimelineHistogramBase instance |
row | Row | Row object. Can be |