-
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 #32555 from phillip-kruger/devui-testing-stacked-bar
Change pie to bar in continuous-testing dev ui
- Loading branch information
Showing
3 changed files
with
136 additions
and
59 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
97 changes: 97 additions & 0 deletions
97
...http/dev-ui-resources/src/main/resources/dev-ui/echarts/echarts-horizontal-stacked-bar.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,97 @@ | ||
import { EchartsAbstractCanvas } from './echarts-abstract-canvas.js'; | ||
/** | ||
* This wraps the Horizontal Stacked Bar echart into a component | ||
* see https://echarts.apache.org/examples/en/editor.html?c=bar-y-category-stack | ||
*/ | ||
class EchartsHorizontalStackedBar extends EchartsAbstractCanvas { | ||
|
||
static get properties() { | ||
return { | ||
name: {type: String}, | ||
height: {type: String}, | ||
sectionTitles: { type: String}, | ||
sectionValues: { type: String}, | ||
sectionColors: { type: String}, | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.name = "Bar"; | ||
this.height = "40px"; | ||
this.sectionTitles = ""; | ||
this.sectionValues = ""; | ||
this.sectionColors = "grey"; | ||
this.primaryTextColor = "--lumo-body-text-color"; | ||
} | ||
|
||
getOption(){ | ||
|
||
let textColor = this.primaryTextColor; | ||
if(textColor.startsWith('--')){ | ||
textColor = getComputedStyle(this.shadowRoot.host).getPropertyValue(textColor); | ||
} | ||
|
||
const sectionColorsArray = this.sectionColors.split(','); | ||
const colors = []; | ||
|
||
for (var cc = 0; cc < sectionColorsArray.length; cc++) { | ||
let colorString = sectionColorsArray[cc]; | ||
if(colorString.startsWith("--")){ | ||
colorString = getComputedStyle(this.shadowRoot.host).getPropertyValue(colorString); | ||
} | ||
colors.push(colorString); | ||
} | ||
|
||
const sectionTitlesArray = this.sectionTitles.split(','); | ||
const sectionValuesArray = this.sectionValues.split(','); | ||
|
||
const option = new Object(); | ||
// Tooltip | ||
option.tooltip = new Object(); | ||
option.tooltip.trigger = "axis"; | ||
// Legend | ||
option.legend = new Object(); | ||
option.legend.show = false; | ||
// Grid | ||
option.grid = new Object(); | ||
option.grid.left = '3%'; | ||
option.grid.right = '4%'; | ||
option.grid.bottom = '3%'; | ||
option.grid.containLabel = false; | ||
// AxisLabel | ||
option.axisLabel = new Object(); | ||
option.axisLabel.color = textColor; | ||
// X Axis | ||
option.xAxis = new Object(); | ||
option.xAxis.type = 'value'; | ||
// Y Axis | ||
option.yAxis = new Object(); | ||
option.yAxis.type = 'category'; | ||
option.yAxis.data = [this.name]; | ||
option.yAxis.show = false; | ||
// Height | ||
option.height = this.height; | ||
|
||
// Series | ||
option.series = []; | ||
|
||
for (var count = 0; count < sectionTitlesArray.length; count++) { | ||
let title = sectionTitlesArray[count]; | ||
let value = sectionValuesArray[count]; | ||
let color = colors[count]; | ||
|
||
const serie = new Object(); | ||
serie.name = title; | ||
serie.type = 'bar'; | ||
serie.stack = 'total'; | ||
serie.data = [value], | ||
serie.color = color; | ||
option.series.push(serie); | ||
} | ||
|
||
return option; | ||
} | ||
|
||
} | ||
customElements.define('echarts-horizontal-stacked-bar', EchartsHorizontalStackedBar); |
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