-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35141 from phillip-kruger/dev-ui-build-steps-chart
Dev UI build steps chart
- Loading branch information
Showing
6 changed files
with
282 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...nsions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/echarts/echarts-bar-stack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { EchartsAbstractCanvas } from './echarts-abstract-canvas.js'; | ||
|
||
/** | ||
* This wraps the Bar Stack echart into a component | ||
* see https://echarts.apache.org/examples/en/editor.html?c=bar-stack | ||
*/ | ||
class EchartsBarStack extends EchartsAbstractCanvas { | ||
|
||
static get properties() { | ||
return { | ||
xdata:{type: String}, | ||
xdataName: {type: String}, | ||
series: { type: String}, | ||
ydataName: {type: String} | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.xdata = null; | ||
this.xdataName = null; | ||
this.series = null; | ||
this.primaryTextColor = "--lumo-body-text-color"; | ||
} | ||
|
||
getOption(){ | ||
|
||
let textColor = this.primaryTextColor; | ||
if(textColor.startsWith('--')){ | ||
textColor = getComputedStyle(this.shadowRoot.host).getPropertyValue(textColor); | ||
} | ||
const barStackOption = new Object(); | ||
|
||
barStackOption.tooltip = new Object(); | ||
barStackOption.tooltip.trigger = "item"; | ||
barStackOption.tooltip.axisPointer= new Object(); | ||
barStackOption.tooltip.axisPointer.type = "shadow"; | ||
barStackOption.tooltip.formatter = function (params) { | ||
let namesUL = "<ul>"; | ||
for (let i = 0; i < params.data.name.length; i++) { | ||
namesUL = namesUL + "<li>" + params.data.name[i] + "</li>"; | ||
} | ||
namesUL = namesUL + "</ul>"; | ||
return ` | ||
<b>${params.seriesName}</b></br> | ||
${namesUL}`; | ||
}; | ||
barStackOption.legend = new Object(); | ||
barStackOption.legend.textStyle = new Object(); | ||
barStackOption.legend.textStyle.color = textColor; | ||
|
||
barStackOption.grid = new Object(); | ||
barStackOption.grid.top = "20%"; | ||
barStackOption.grid.left = "3%"; | ||
barStackOption.grid.right = "4%"; | ||
barStackOption.grid.bottom = "3%"; | ||
barStackOption.grid.containLabel = true; | ||
|
||
let xAxis = new Object(); | ||
xAxis.type = "category"; | ||
|
||
xAxis.data = this.xdata.split(','); | ||
xAxis.axisLine = new Object(); | ||
xAxis.axisLine.lineStyle = new Object(); | ||
xAxis.axisLine.lineStyle.color = textColor; | ||
if(this.xdataName){ | ||
xAxis.name = this.xdataName; | ||
xAxis.nameLocation = "center"; | ||
xAxis.nameGap = 30; | ||
} | ||
barStackOption.xAxis = []; | ||
barStackOption.xAxis.push(xAxis); | ||
|
||
let yAxis = new Object(); | ||
yAxis.type = "value"; | ||
yAxis.axisLine = new Object(); | ||
yAxis.axisLine.lineStyle = new Object(); | ||
yAxis.axisLine.lineStyle.color = textColor; | ||
if(this.ydataName){ | ||
yAxis.name = this.ydataName; | ||
yAxis.nameLocation = "center"; | ||
yAxis.nameGap = 30; | ||
} | ||
|
||
barStackOption.yAxis = []; | ||
barStackOption.yAxis.push(yAxis); | ||
|
||
barStackOption.series = []; | ||
let seriesMap = new Map(Object.entries(JSON.parse(this.series))); | ||
|
||
|
||
for (let [key, value] of seriesMap) { | ||
let arr = []; | ||
|
||
for (let i = 0; i < value.length; i++) { | ||
let val = value[i]; | ||
|
||
|
||
let dataItem = new Object(); | ||
dataItem.name = val; | ||
dataItem.label = new Object(); | ||
if(val.length > 0){ | ||
dataItem.value = 1; | ||
} | ||
arr.push(dataItem); | ||
} | ||
|
||
const serie = new Object(); | ||
serie.name = key; | ||
serie.type = "bar"; | ||
serie.stack = "stack"; | ||
serie.emphasis = new Object(); | ||
serie.emphasis.focus = "series"; | ||
|
||
serie.data = arr; | ||
barStackOption.series.push(serie); | ||
} | ||
|
||
return barStackOption; | ||
|
||
} | ||
|
||
} | ||
customElements.define('echarts-bar-stack', EchartsBarStack); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...tx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps-execution-graph.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { LitElement, html, css} from 'lit'; | ||
import { JsonRpc } from 'jsonrpc'; | ||
import 'echarts-bar-stack'; | ||
import '@vaadin/button'; | ||
import '@vaadin/checkbox'; | ||
import '@vaadin/checkbox-group'; | ||
import '@vaadin/progress-bar'; | ||
|
||
/** | ||
* This component shows the Build Step Execution Graph | ||
*/ | ||
export class QwcBuildStepsExecutionGraph extends LitElement { | ||
|
||
static styles = css` | ||
.top-bar { | ||
display: flex; | ||
align-items: baseline; | ||
gap: 20px; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
.top-bar h4 { | ||
color: var(--lumo-contrast-60pct); | ||
} | ||
`; | ||
|
||
static properties = { | ||
extensionName: {type: String}, // TODO: Add 'pane' concept in router to register internal extension pages. | ||
_threadSlotRecords: {state: true}, | ||
_slots: {state: true} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this._threadSlotRecords = null; | ||
this._slots = null; | ||
} | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
this.jsonRpc = new JsonRpc(this.extensionName); | ||
this._fetchBuildStepsExecutionData(); | ||
} | ||
|
||
_fetchBuildStepsExecutionData(){ | ||
this.jsonRpc.getThreadSlotRecords().then(jsonRpcResponse => { | ||
this._slots = jsonRpcResponse.result.slots; | ||
this._threadSlotRecords = jsonRpcResponse.result.threadSlotRecords; | ||
}); | ||
} | ||
|
||
render() { | ||
|
||
if(this._threadSlotRecords){ | ||
let xdata = this._slots.toString(); | ||
let xname = this._slots.length + " time slots (" + this._slots[0] +" ms)"; | ||
let yname = "Number of build threads used in a time slot"; | ||
return html`${this._renderTopBar()} | ||
<echarts-bar-stack width="400px" height="400px" | ||
xdata="${xdata}" | ||
xdataName="${xname}" | ||
ydataName="${yname}" | ||
series="${JSON.stringify(this._threadSlotRecords)}"> | ||
</echarts-bar-stack> | ||
`; | ||
}else{ | ||
return html` | ||
<div style="color: var(--lumo-secondary-text-color);width: 95%;" > | ||
<div>Loading Build Steps Execution Graph...</div> | ||
<vaadin-progress-bar indeterminate></vaadin-progress-bar> | ||
</div> | ||
`; | ||
} | ||
|
||
|
||
} | ||
|
||
_renderTopBar(){ | ||
return html` | ||
<div class="top-bar"> | ||
<vaadin-button @click="${this._backAction}"> | ||
<vaadin-icon icon="font-awesome-solid:caret-left" slot="prefix"></vaadin-icon> | ||
Back | ||
</vaadin-button> | ||
<h4>Build Steps Concurrent Execution Chart</h4> | ||
</div>`; | ||
} | ||
|
||
_backAction(){ | ||
const back = new CustomEvent("build-steps-graph-back", { | ||
detail: {}, | ||
bubbles: true, | ||
cancelable: true, | ||
composed: false, | ||
}); | ||
this.dispatchEvent(back); | ||
} | ||
} | ||
customElements.define('qwc-build-steps-execution-graph', QwcBuildStepsExecutionGraph); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.