apucher closed pull request #3344: [TE] rootcause - display step chart for
daily metrics
URL: https://github.com/apache/incubator-pinot/pull/3344
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-chart/component.js
b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-chart/component.js
index 2f86200aa4..6aba57ab36 100644
---
a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-chart/component.js
+++
b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-chart/component.js
@@ -400,11 +400,17 @@ export default Component.extend({
const { entities, timeseries, timeseriesMode, _eventValues, context } =
this.getProperties('entities', 'timeseries', 'timeseriesMode',
'_eventValues', 'context');
+ const timeseriesPostProcessing = (metricEntity, timeseries) => {
+ return (metricEntity.attributes.granularity[0] === '1_DAYS' ||
context.granularity === '1_DAYS') ?
+ this._convertToDailyStepSeries(timeseries) : timeseries;
+ }
+
if (hasPrefix(urn, 'frontend:metric:current:')) {
const metricEntity = entities[toMetricUrn(urn)];
+ const outputTimeseries = timeseriesPostProcessing(metricEntity,
timeseries[urn]);
const series = {
- timestamps: timeseries[urn].timestamp,
- values: timeseries[urn].value,
+ timestamps: outputTimeseries.timestamp,
+ values: outputTimeseries.value,
color: metricEntity ? metricEntity.color : 'none',
type: 'line',
axis: 'y'
@@ -414,9 +420,10 @@ export default Component.extend({
} else if (hasPrefix(urn, 'frontend:metric:baseline:')) {
const metricEntity = entities[toMetricUrn(urn)];
+ const outputTimeseries = timeseriesPostProcessing(metricEntity,
timeseries[urn]);
const series = {
- timestamps: timeseries[urn].timestamp,
- values: timeseries[urn].value,
+ timestamps: outputTimeseries.timestamp,
+ values: outputTimeseries.value,
color: metricEntity ? 'light-' + metricEntity.color : 'none',
type: 'line',
axis: 'y'
@@ -439,6 +446,34 @@ export default Component.extend({
}
},
+ /**
+ * Returns a post-processed timeseries emulating a step function (because C3
support is insufficient)
+ *
+ * @param {Array} timeseries timeseries
+ * @returns {{timestamp: Array, value: Array}}
+ * @private
+ */
+ _convertToDailyStepSeries(timeseries) {
+ const newTimeseries = {
+ timestamp: [],
+ value: []
+ };
+
+ // crudely guess end timestamp
+ const virtualEnd = timeseries.timestamp[timeseries.timestamp.length - 1] +
86400000;
+ const virtualTimestamps = [...timeseries.timestamp, virtualEnd];
+
+ for (let i = 0; i < virtualTimestamps.length - 1; i++) {
+ newTimeseries.timestamp.push(virtualTimestamps[i]);
+ newTimeseries.timestamp.push(virtualTimestamps[i + 1] - 1);
+
+ newTimeseries.value.push(timeseries.value[i]);
+ newTimeseries.value.push(timeseries.value[i]);
+ }
+
+ return newTimeseries;
+ },
+
/**
* Returns a timeseries transformed by mode.
*
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]