From 4972226de86b4e368bd6316fca46fe52f7f45a1d Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Tue, 23 Apr 2024 15:35:20 +0200 Subject: [PATCH 1/8] Add missing types to settings --- capabilities.json | 9 +--- src/barChartSettingsModel.ts | 84 ++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/capabilities.json b/capabilities.json index 9ec0298..afd5211 100644 --- a/capabilities.json +++ b/capabilities.json @@ -137,14 +137,7 @@ }, "position": { "type": { - "enumeration": [ - { - "value": "Left" - }, - { - "value": "Right" - } - ] + "enumeration": [] } } } diff --git a/src/barChartSettingsModel.ts b/src/barChartSettingsModel.ts index 4984840..b42501c 100644 --- a/src/barChartSettingsModel.ts +++ b/src/barChartSettingsModel.ts @@ -4,34 +4,42 @@ import { BarChartDataPoint } from "./barChart"; import Card = formattingSettings.SimpleCard; import Model = formattingSettings.Model; +import Slice = formattingSettings.Slice; +import ColorPicker = formattingSettings.ColorPicker; +import ToggleSwitch = formattingSettings.ToggleSwitch; +import NumUpDown = formattingSettings.NumUpDown; +import TextInput = formattingSettings.TextInput; +import ItemDropdown = formattingSettings.ItemDropdown; +import FontControl = formattingSettings.FontControl; +import FontPicker = formattingSettings.FontPicker; class EnableAxisCardSettings extends Card { - show = new formattingSettings.ToggleSwitch({ + show = new ToggleSwitch({ name: "show", displayName: undefined, value: false, }); - fill = new formattingSettings.ColorPicker({ + fill = new ColorPicker({ name: "fill", displayName: "Color", value: { value: "#000000" } }); - topLevelSlice = this.show; + topLevelSlice: ToggleSwitch = this.show; name: string = "enableAxis"; displayName: string = "Enable Axis"; - slices = [this.fill]; + slices: Slice[] = [this.fill]; } class ColorSelectorCardSettings extends Card { name: string = "colorSelector"; displayName: string = "Data Colors"; - slices = []; + slices: Slice[] = []; } class GeneralViewCardSettings extends Card { - opacity = new formattingSettings.NumUpDown({ + opacity = new NumUpDown({ name: "opacity", displayName: "Bars Opacity", value: 100, @@ -47,7 +55,7 @@ class GeneralViewCardSettings extends Card { } }); - showHelpLink = new formattingSettings.ToggleSwitch({ + showHelpLink = new ToggleSwitch({ name: "showHelpLink", displayName: "Show Help Button", value: false @@ -56,71 +64,71 @@ class GeneralViewCardSettings extends Card { name: string = "generalView"; displayName: string = "General View"; helpLinkColor: string = "#80B0E0" - slices = [this.opacity, this.showHelpLink]; + slices: Slice[] = [this.opacity, this.showHelpLink]; } class AverageLineCardSettings extends Card { - show = new formattingSettings.ToggleSwitch({ + show = new ToggleSwitch({ name: "show", displayName: undefined, value: false, }); - fill = new formattingSettings.ColorPicker({ + fill = new ColorPicker({ name: "fill", displayName: "Color", value: { value: "#888888" }, }); - showDataLabel = new formattingSettings.ToggleSwitch({ + showDataLabel = new ToggleSwitch({ name: "showDataLabel", displayName: "Data Label", value: false }); - topLevelSlice = this.show; + topLevelSlice: ToggleSwitch = this.show; name: string = "averageLine"; displayName: string = "Average Line"; analyticsPane: boolean = true; - slices = [this.show, this.fill, this.showDataLabel]; + slices: Slice[] = [this.show, this.fill, this.showDataLabel]; } class DirectEditSettings extends Card { - displayName = 'Direct Edit'; - name = 'directEdit'; + displayName: string = "Direct Edit"; + name: string = "directEdit"; private minFontSize: number = 8; private defaultFontSize: number = 11; - private positionOptions: powerbiVisualsApi.IEnumMember[] = [{ displayName: 'Right', value: 'Right' }, { displayName: 'Left', value: 'Left' }] - show = new formattingSettings.ToggleSwitch({ + private positionOptions: powerbiVisualsApi.IEnumMember[] = [{ displayName: "Right", value: "Right" }, { displayName: "Left", value: "Left" }] + show = new ToggleSwitch({ name: "show", displayName: undefined, value: true, }); - topLevelSlice = this.show; - textProperty = new formattingSettings.TextInput({ + topLevelSlice: ToggleSwitch = this.show; + textProperty = new TextInput({ displayName: "Text Property", name: "textProperty", value: "What is your quest?", placeholder: "" }); - position = new formattingSettings.ItemDropdown({ - name: 'position', - displayName: 'Position', + position = new ItemDropdown({ + name: "position", + displayName: "Position", items: this.positionOptions, value: this.positionOptions[0] }); - font = new formattingSettings.FontControl({ + font = new FontControl({ name: "font", - displayName: 'Font', - fontFamily: new formattingSettings.FontPicker({ + displayName: "Font", + fontFamily: new FontPicker({ name: "fontFamily", displayName: "Font Family", value: "Segoe UI, wf_segoe-ui_normal, helvetica, arial, sans-serif" }), - fontSize: new formattingSettings.NumUpDown({ + fontSize: new NumUpDown({ name: "fontSize", displayName: "Font Size", value: this.defaultFontSize, @@ -131,34 +139,34 @@ class DirectEditSettings extends Card { } } }), - bold: new formattingSettings.ToggleSwitch({ - name: 'bold', + bold: new ToggleSwitch({ + name: "bold", displayName: "bold", value: true }), - italic: new formattingSettings.ToggleSwitch({ - name: 'italic', + italic: new ToggleSwitch({ + name: "italic", displayName: "italic", value: true }), - underline: new formattingSettings.ToggleSwitch({ - name: 'underline', + underline: new ToggleSwitch({ + name: "underline", displayName: "underline", value: true }) }); - fontColor = new formattingSettings.ColorPicker({ + fontColor = new ColorPicker({ name: "fontColor", displayName: "Color", value: { value: "#000000" } }); - background = new formattingSettings.ColorPicker({ + background = new ColorPicker({ name: "background", displayName: "Background Color", value: { value: "#FFFFFF" } }); - slices = [this.textProperty, this.font, this.fontColor, this.background, this.position]; + slices: Slice[] = [this.textProperty, this.font, this.fontColor, this.background, this.position]; } /** @@ -170,17 +178,17 @@ export class BarChartSettingsModel extends Model { generalView = new GeneralViewCardSettings(); averageLine = new AverageLineCardSettings(); directEditSettings = new DirectEditSettings(); - cards = [this.enableAxis, this.colorSelector, this.generalView, this.averageLine, this.directEditSettings]; + cards: Card[] = [this.enableAxis, this.colorSelector, this.generalView, this.averageLine, this.directEditSettings]; /** * populate colorSelector object categories formatting properties * @param dataPoints */ populateColorSelector(dataPoints: BarChartDataPoint[]) { - const slices: formattingSettings.ColorPicker[] = this.colorSelector.slices; + const slices: Slice[] = this.colorSelector.slices; if (dataPoints) { dataPoints.forEach(dataPoint => { - slices.push(new formattingSettings.ColorPicker({ + slices.push(new ColorPicker({ name: "fill", displayName: dataPoint.category, value: { value: dataPoint.color }, From 20fb1907caa73637bf870c3726ff28316fc79078 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Tue, 23 Apr 2024 16:08:37 +0200 Subject: [PATCH 2/8] Add types to barchart.ts --- src/barChart.ts | 254 ++++++++++++++++++++++-------------------------- 1 file changed, 116 insertions(+), 138 deletions(-) diff --git a/src/barChart.ts b/src/barChart.ts index 40ee050..1f93d89 100644 --- a/src/barChart.ts +++ b/src/barChart.ts @@ -6,29 +6,28 @@ import { import { scaleBand, scaleLinear, - ScaleLinear + ScaleLinear, + ScaleBand } from "d3-scale"; -import { axisBottom } from "d3-axis"; +import { Axis, axisBottom } from "d3-axis"; -import powerbiVisualsApi from "powerbi-visuals-api"; +import powerbi from "powerbi-visuals-api"; import { createTooltipServiceWrapper, ITooltipServiceWrapper } from "powerbi-visuals-utils-tooltiputils"; import { FormattingSettingsService } from "powerbi-visuals-utils-formattingmodel"; import { textMeasurementService, valueFormatter } from "powerbi-visuals-utils-formattingutils"; import { HtmlSubSelectableClass, HtmlSubSelectionHelper, SubSelectableDirectEdit as SubSelectableDirectEditAttr, SubSelectableDisplayNameAttribute, SubSelectableObjectNameAttribute, SubSelectableTypeAttribute -} from 'powerbi-visuals-utils-onobjectutils'; +} from "powerbi-visuals-utils-onobjectutils"; +import { dataViewObjects} from "powerbi-visuals-utils-dataviewutils"; import { BarChartSettingsModel } from "./barChartSettingsModel"; import { getLocalizedString } from "./localization/localizationHelper" -import { getValue, getCategoricalObjectValue } from "./objectEnumerationUtility"; import "./../style/visual.less"; -import powerbi = powerbiVisualsApi; - -type Selection = d3Selection; +type Selection = d3Selection; // powerbi.visuals import CustomVisualSubSelection = powerbi.visuals.CustomVisualSubSelection; @@ -45,6 +44,7 @@ import SubSelectableDirectEdit = powerbi.visuals.SubSelectableDirectEdit; import SubSelectableDirectEditStyle = powerbi.visuals.SubSelectableDirectEditStyle; import SubSelectionStyles = powerbi.visuals.SubSelectionStyles; import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions; +import DataViewObjectPropertyIdentifier = powerbi.DataViewObjectPropertyIdentifier; import VisualShortcutType = powerbi.visuals.VisualShortcutType; import VisualSubSelectionShortcuts = powerbi.visuals.VisualSubSelectionShortcuts; import VisualTooltipDataItem = powerbi.extensibility.VisualTooltipDataItem; @@ -93,80 +93,80 @@ interface References { } const enum BarChartObjectNames { - ArcElement = 'arcElement', - ColorSelector = 'colorSelector', - EnableAxis = 'enableAxis', - DirectEdit = 'directEdit' + ArcElement = "arcElement", + ColorSelector = "colorSelector", + EnableAxis = "enableAxis", + DirectEdit = "directEdit" } const DirectEdit: SubSelectableDirectEdit = { reference: { - objectName: 'directEdit', - propertyName: 'textProperty' + objectName: "directEdit", + propertyName: "textProperty" }, style: SubSelectableDirectEditStyle.Outline, }; const colorSelectorReferences: References = { - cardUid: 'Visual-colorSelector-card', - groupUid: 'colorSelector-group', + cardUid: "Visual-colorSelector-card", + groupUid: "colorSelector-group", fill: { objectName: BarChartObjectNames.ColorSelector, - propertyName: 'fill' + propertyName: "fill" } }; const enableAxisReferences: References = { - cardUid: 'Visual-enableAxis-card', - groupUid: 'enableAxis-group', + cardUid: "Visual-enableAxis-card", + groupUid: "enableAxis-group", fill: { objectName: BarChartObjectNames.EnableAxis, - propertyName: 'fill' + propertyName: "fill" }, show: { objectName: BarChartObjectNames.EnableAxis, - propertyName: 'show' + propertyName: "show" } }; const directEditReferences: References = { - cardUid: 'Visual-directEdit-card', - groupUid: 'directEdit-group', + cardUid: "Visual-directEdit-card", + groupUid: "directEdit-group", fontFamily: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'fontFamily' + propertyName: "fontFamily" }, bold: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'bold' + propertyName: "bold" }, italic: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'italic' + propertyName: "italic" }, underline: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'underline' + propertyName: "underline" }, fontSize: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'fontSize' + propertyName: "fontSize" }, fontColor: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'fontColor' + propertyName: "fontColor" }, show: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'show' + propertyName: "show" }, position: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'position' + propertyName: "position" }, textProperty: { objectName: BarChartObjectNames.DirectEdit, - propertyName: 'textProperty' + propertyName: "textProperty" } }; @@ -243,13 +243,17 @@ function getColumnColorByIndex( } }; - return getCategoricalObjectValue( - category, - index, - 'colorSelector', - 'fill', - defaultColor - ).solid.color; + const prop: DataViewObjectPropertyIdentifier = { + objectName: "colorSelector", + propertyName: "fill" + }; + + let colorFromObjects: Fill; + if(category.objects?.[index]){ + colorFromObjects = dataViewObjects.getValue(category?.objects[index], prop); + } + + return colorFromObjects?.solid.color ?? defaultColor.solid.color; } function getColumnStrokeColor(colorPalette: ISandboxExtendedColorPalette): string { @@ -264,27 +268,6 @@ function getColumnStrokeWidth(isHighContrast: boolean): number { : 0; } -function getAxisTextFillColor( - objects: DataViewObjects, - colorPalette: ISandboxExtendedColorPalette, - defaultColor: string -): string { - if (colorPalette.isHighContrast) { - return colorPalette.foreground.value; - } - - return getValue( - objects, - "enableAxis", - "fill", - { - solid: { - color: defaultColor, - } - }, - ).solid.color; -} - export class BarChart implements IVisual { private averageLine: Selection; private barContainer: Selection; @@ -299,14 +282,14 @@ export class BarChart implements IVisual { private LandingPageRemoved: boolean; private locale: string; private selectionManager: ISelectionManager; - private svg: Selection; + private svg: Selection; private tooltipServiceWrapper: ITooltipServiceWrapper; - private xAxis: Selection; - private barSelection: Selection; + private xAxis: Selection; + private barSelection: Selection; private subSelectionHelper: HtmlSubSelectionHelper; private formatMode: boolean = false; - private directEditElement: Selection; + private directEditElement: Selection; private visualDirectEditSubSelection = JSON.stringify(DirectEdit); public visualOnObjectFormatting?: powerbi.extensibility.visual.VisualOnObjectFormatting; @@ -354,16 +337,16 @@ export class BarChart implements IVisual { }); this.svg = d3Select(options.element) - .append('svg') - .classed('barChart', true); + .append("svg") + .classed("barChart", true); this.barContainer = this.svg - .append('g') - .classed('barContainer', true); + .append("g") + .classed("barContainer", true); this.xAxis = this.svg - .append('g') - .classed('xAxis', true); + .append("g") + .classed("xAxis", true); this.initAverageLine(); @@ -423,55 +406,50 @@ export class BarChart implements IVisual { .style("font-size", Math.min(height, width) * BarChart.Config.xAxisFontMultiplier) .style("fill", this.formattingSettings.enableAxis.fill.value.value); - const yScale = scaleLinear() + const yScale: ScaleLinear = scaleLinear() .domain([0, options.dataViews[0].categorical.values[0].maxLocal]) .range([height, 0]); - const xScale = scaleBand() + const xScale: ScaleBand = scaleBand() .domain(this.barDataPoints.map(d => d.category)) .rangeRound([0, width]) .padding(0.2); - const xAxis = axisBottom(xScale); - const colorObjects = options.dataViews[0] ? options.dataViews[0].metadata.objects : null; - this.xAxis.attr('transform', 'translate(0, ' + height + ')') + const xAxis: Axis = axisBottom(xScale); + this.xAxis.attr("transform", "translate(0, " + height + ")") .call(xAxis) - .attr("color", getAxisTextFillColor( - colorObjects, - this.host.colorPalette, - this.formattingSettings.enableAxis.fill.value.value - )); + .attr("color", this.formattingSettings.enableAxis.fill.value.value); - const textNodes = this.xAxis.selectAll("text"); + const textNodes: Selection = this.xAxis.selectAll("text"); textNodes - .attr(SubSelectableObjectNameAttribute, 'enableAxis') - .attr(SubSelectableDisplayNameAttribute, 'x-Axis') + .attr(SubSelectableObjectNameAttribute, "enableAxis") + .attr(SubSelectableDisplayNameAttribute, "x-Axis") .attr(SubSelectableTypeAttribute, powerbi.visuals.SubSelectionStylesType.Shape) .classed(HtmlSubSelectableClass, options.formatMode && this.formattingSettings.enableAxis.show.value); BarChart.wordBreak(textNodes, xScale.bandwidth(), height); this.handleAverageLineUpdate(height, width, yScale); this.barSelection = this.barContainer - .selectAll('.bar') + .selectAll(".bar") .data(this.barDataPoints); const barSelectionMerged = this.barSelection .enter() - .append('rect') + .append("rect") .merge(this.barSelection); - barSelectionMerged.classed('bar', true); + barSelectionMerged.classed("bar", true); const opacity: number = this.formattingSettings.generalView.opacity.value / 100; barSelectionMerged - .attr(SubSelectableObjectNameAttribute, 'colorSelector') + .attr(SubSelectableObjectNameAttribute, "colorSelector") .attr(SubSelectableDisplayNameAttribute, (dataPoint: BarChartDataPoint) => this.formattingSettings.colorSelector.slices[dataPoint.index].displayName) .attr(SubSelectableTypeAttribute, powerbi.visuals.SubSelectionStylesType.Shape) .classed(HtmlSubSelectableClass, options.formatMode) .attr("width", xScale.bandwidth()) - .attr("height", d => height - yScale(d.value)) - .attr("y", d => yScale(d.value)) - .attr("x", d => xScale(d.category)) + .attr("height", (dataPoint: BarChartDataPoint) => height - yScale(dataPoint.value)) + .attr("y", (dataPoint: BarChartDataPoint) => yScale(dataPoint.value)) + .attr("x", (dataPoint: BarChartDataPoint) => xScale(dataPoint.category)) .style("fill-opacity", opacity) .style("stroke-opacity", opacity) .style("fill", (dataPoint: BarChartDataPoint) => dataPoint.color) @@ -508,9 +486,9 @@ export class BarChart implements IVisual { } private removeEventHandlers(barSelectionMerged: d3Selection) { - barSelectionMerged.on('click', null); - this.svg.on('click', null); - this.svg.on('contextmenu', null); + barSelectionMerged.on("click", null); + this.svg.on("click", null); + this.svg.on("contextmenu", null); } private addEventHandlers(barSelectionMerged: d3Selection) { @@ -521,24 +499,24 @@ export class BarChart implements IVisual { private updateDirectEditElementFormat() { this.directEditElement - .classed('direct-edit', true) - .classed('hidden', !this.formattingSettings.directEditSettings.show.value) + .classed("direct-edit", true) + .classed("hidden", !this.formattingSettings.directEditSettings.show.value) .classed(HtmlSubSelectableClass, this.formatMode && this.formattingSettings.directEditSettings.show.value) - .attr(SubSelectableObjectNameAttribute, 'directEdit') - .attr(SubSelectableDisplayNameAttribute, 'Direct Edit') + .attr(SubSelectableObjectNameAttribute, "directEdit") + .attr(SubSelectableDisplayNameAttribute, "Direct Edit") .attr(SubSelectableDirectEditAttr, this.visualDirectEditSubSelection) - .style('font-family', this.formattingSettings.directEditSettings.font.fontFamily.value) - .style('color', this.formattingSettings.directEditSettings.fontColor.value.value) - .style('font-style', this.formattingSettings.directEditSettings.font.italic.value ? 'italic' : 'normal') - .style('text-decoration', this.formattingSettings.directEditSettings.font.underline.value ? 'underline' : 'none') - .style('font-weight', this.formattingSettings.directEditSettings.font.bold.value ? 'bold' : 'normal') - .style('right', this.formattingSettings.directEditSettings.position.value.value === 'Right' ? '12px' : '60px') - .style('background-color', this.formattingSettings.directEditSettings.background.value.value) - .style('font-size', `${this.formattingSettings.directEditSettings.font.fontSize.value}px`) + .style("font-family", this.formattingSettings.directEditSettings.font.fontFamily.value) + .style("color", this.formattingSettings.directEditSettings.fontColor.value.value) + .style("font-style", this.formattingSettings.directEditSettings.font.italic.value ? "italic" : "normal") + .style("text-decoration", this.formattingSettings.directEditSettings.font.underline.value ? "underline" : "none") + .style("font-weight", this.formattingSettings.directEditSettings.font.bold.value ? "bold" : "normal") + .style("right", this.formattingSettings.directEditSettings.position.value.value === "Right" ? "12px" : "60px") + .style("background-color", this.formattingSettings.directEditSettings.background.value.value) + .style("font-size", `${this.formattingSettings.directEditSettings.font.fontSize.value}px`) .text(this.formattingSettings.directEditSettings.textProperty.value); } private static wordBreak( - textNodes: Selection, + textNodes: Selection, allowedWidth: number, maxHeight: number ) { @@ -551,7 +529,7 @@ export class BarChart implements IVisual { } private handleBarClick(barSelectionMerged: Selection) { - barSelectionMerged.on('click', (event: Event, datum: BarChartDataPoint) => { + barSelectionMerged.on("click", (event: Event, datum: BarChartDataPoint) => { // Allow selection only if the visual is rendered in a view that supports interactivity (e.g. Report) if (this.host.hostCapabilities.allowInteractions) { const isCtrlPressed: boolean = (event).ctrlKey; @@ -568,7 +546,7 @@ export class BarChart implements IVisual { private handleClick(barSelection: Selection) { // Clear selection when clicking outside a bar - this.svg.on('click', () => { + this.svg.on("click", () => { if (this.host.hostCapabilities.allowInteractions) { this.selectionManager .clear() @@ -580,7 +558,7 @@ export class BarChart implements IVisual { } private handleContextMenu() { - this.svg.on('contextmenu', (event) => { + this.svg.on("contextmenu", (event) => { const mouseEvent: MouseEvent = event; const eventTarget: EventTarget = mouseEvent.target; const dataPoint: any = d3Select(eventTarget).datum(); @@ -593,7 +571,7 @@ export class BarChart implements IVisual { } private syncSelectionState( - selection: Selection, + selection: Selection, selectionIds: ISelectionId[] ): void { if (!selection || !selectionIds) { @@ -637,7 +615,7 @@ export class BarChart implements IVisual { * Returns properties pane formatting model content hierarchies, properties and latest formatting values, Then populate properties pane. * This method is called once every time we open properties pane or when the user edit any format property. */ - public getFormattingModel(): powerbiVisualsApi.visuals.FormattingModel { + public getFormattingModel(): powerbi.visuals.FormattingModel { return this.formattingSettingsService.buildFormattingModel(this.formattingSettings); } @@ -684,7 +662,7 @@ export class BarChart implements IVisual { { type: VisualShortcutType.Navigate, destinationInfo: { cardUid: colorSelectorReferences.cardUid }, - label: 'Color' + label: "Color" } ]; } @@ -694,7 +672,7 @@ export class BarChart implements IVisual { return { type: SubSelectionStylesType.Shape, fill: { - label: 'Fill', + label: "Fill", reference: { ...colorSelectorReferences.fill, selector @@ -710,7 +688,7 @@ export class BarChart implements IVisual { reference: { ...enableAxisReferences.fill }, - label: 'Enable Axis' + label: "Enable Axis" } } } @@ -732,13 +710,13 @@ export class BarChart implements IVisual { ...enableAxisReferences.show }], ...enableAxisReferences.show, - disabledLabel: 'Delete', - enabledLabel: 'Delete' + disabledLabel: "Delete", + enabledLabel: "Delete" }, { type: VisualShortcutType.Navigate, destinationInfo: { cardUid: enableAxisReferences.cardUid }, - label: 'EnableAxis' + label: "EnableAxis" } ]; } @@ -763,18 +741,18 @@ export class BarChart implements IVisual { ...directEditReferences.show, }], ...directEditReferences.show, - disabledLabel: 'Delete', + disabledLabel: "Delete", }, { type: VisualShortcutType.Picker, ...directEditReferences.position, - label: 'Position' + label: "Position" }, { type: VisualShortcutType.Navigate, destinationInfo: { cardUid: directEditReferences.cardUid }, - label: 'Direct edit' + label: "Direct edit" } ]; } @@ -786,44 +764,44 @@ export class BarChart implements IVisual { reference: { ...directEditReferences.fontFamily }, - label: 'font' + label: "font" }, bold: { reference: { ...directEditReferences.bold }, - label: 'font' + label: "font" }, italic: { reference: { ...directEditReferences.italic }, - label: 'font' + label: "font" }, underline: { reference: { ...directEditReferences.underline }, - label: 'font' + label: "font" }, fontSize: { reference: { ...directEditReferences.fontSize }, - label: 'font' + label: "font" }, fontColor: { reference: { ...directEditReferences.fontColor }, - label: 'fontColor' + label: "fontColor" }, background: { reference: { - objectName: 'directEdit', - propertyName: 'background' + objectName: "directEdit", + propertyName: "background" }, - label: 'background' + label: "background" } }; } @@ -842,8 +820,8 @@ export class BarChart implements IVisual { } private creatDirectEditElement(): Element { - const element = document.createElement('div'); - element.setAttribute('class', 'direct-edit'); + const element = document.createElement("div"); + element.setAttribute("class", "direct-edit"); return element; } @@ -924,7 +902,7 @@ export class BarChart implements IVisual { } // If plain string, just return it - if (typeof (color) === 'string') { + if (typeof (color) === "string") { return color; } // Otherwise, extract string representation from Fill type object @@ -933,14 +911,14 @@ export class BarChart implements IVisual { private initAverageLine() { this.averageLine = this.svg - .append('g') - .classed('averageLine', true); + .append("g") + .classed("averageLine", true); - this.averageLine.append('line') - .attr('id', 'averageLine'); + this.averageLine.append("line") + .attr("id", "averageLine"); - this.averageLine.append('text') - .attr('id', 'averageLineLabel'); + this.averageLine.append("text") + .attr("id", "averageLineLabel"); } private handleAverageLineUpdate(height: number, width: number, yScale: ScaleLinear) { From ec03207bca719bd7ccc5b43e53d2806ef4930053 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Tue, 23 Apr 2024 16:12:23 +0200 Subject: [PATCH 3/8] Remove object enumeration utility --- src/objectEnumerationUtility.ts | 56 --------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/objectEnumerationUtility.ts diff --git a/src/objectEnumerationUtility.ts b/src/objectEnumerationUtility.ts deleted file mode 100644 index bb96123..0000000 --- a/src/objectEnumerationUtility.ts +++ /dev/null @@ -1,56 +0,0 @@ -import powerbiVisualsApi from "powerbi-visuals-api"; -import powerbi = powerbiVisualsApi; - -import DataViewObject = powerbi.DataViewObject; -import DataViewObjects = powerbi.DataViewObjects; -import DataViewCategoryColumn = powerbi.DataViewCategoryColumn; - -/** - * Gets property value for a particular object. - * - * @function - * @param {DataViewObjects} objects - Map of defined objects. - * @param {string} objectName - Name of desired object. - * @param {string} propertyName - Name of desired property. - * @param {T} defaultValue - Default value of desired property. - */ -export function getValue(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: T): T { - if (objects) { - const object = objects[objectName]; - if (object) { - const property: T = object[propertyName]; - if (property !== undefined) { - return property; - } - } - } - return defaultValue; -} - -/** - * Gets property value for a particular object in a category. - * - * @function - * @param {DataViewCategoryColumn} category - List of category objects. - * @param {number} index - Index of category object. - * @param {string} objectName - Name of desired object. - * @param {string} propertyName - Name of desired property. - * @param {T} defaultValue - Default value of desired property. - */ -export function getCategoricalObjectValue(category: DataViewCategoryColumn, index: number, objectName: string, propertyName: string, defaultValue: T): T { - const categoryObjects = category.objects; - - if (categoryObjects) { - const categoryObject: DataViewObject = categoryObjects[index]; - if (categoryObject) { - const object = categoryObject[objectName]; - if (object) { - const property: T = object[propertyName]; - if (property !== undefined) { - return property; - } - } - } - } - return defaultValue; -} \ No newline at end of file From 82ad261df19d08b607fdbd54ed22c686d9dc9616 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Wed, 24 Apr 2024 11:40:53 +0200 Subject: [PATCH 4/8] Add localization manager --- src/barChart.ts | 9 +-- src/localization/localizationHelper.ts | 67 -------------------- src/localization/localizedResources.ts | 52 --------------- stringResources/ar-SA/resources.resjson | 3 + stringResources/bg-BG/resources.resjson | 3 + stringResources/ca-ES/resources.resjson | 3 + stringResources/cs-CZ/resources.resjson | 3 + stringResources/da-DK/resources.resjson | 3 + stringResources/de-DE/resources.resjson | 3 + stringResources/el-GR/resources.resjson | 3 + stringResources/en-US/resources.resjson | 3 + stringResources/es-ES/resources.resjson | 3 + stringResources/et-EE/resources.resjson | 3 + stringResources/eu-ES/resources.resjson | 3 + stringResources/fi-FI/resources.resjson | 3 + stringResources/fr-FR/resources.resjson | 3 + stringResources/gl-ES/resources.resjson | 3 + stringResources/he-IL/resources.resjson | 3 + stringResources/hi-IN/resources.resjson | 3 + stringResources/hr-HR/resources.resjson | 3 + stringResources/hu-HU/resources.resjson | 3 + stringResources/id-ID/resources.resjson | 3 + stringResources/it-IT/resources.resjson | 3 + stringResources/ja-JP/resources.resjson | 3 + stringResources/kk-KZ/resources.resjson | 3 + stringResources/ko-KR/resources.resjson | 3 + stringResources/lt-LT/resources.resjson | 3 + stringResources/lv-LV/resources.resjson | 3 + stringResources/ms-MY/resources.resjson | 3 + stringResources/nb-NO/resources.resjson | 3 + stringResources/nl-NL/resources.resjson | 3 + stringResources/pl-PL/resources.resjson | 3 + stringResources/pt-BR/resources.resjson | 3 + stringResources/pt-PT/resources.resjson | 3 + stringResources/ro-RO/resources.resjson | 3 + stringResources/ru-RU/resources.resjson | 3 + stringResources/sk-SK/resources.resjson | 3 + stringResources/sl-SI/resources.resjson | 3 + stringResources/sr-Cyrl-RS/resources.resjson | 3 + stringResources/sr-Latn-RS/resources.resjson | 3 + stringResources/sv-SE/resources.resjson | 3 + stringResources/th-TH/resources.resjson | 3 + stringResources/tr-TR/resources.resjson | 3 + stringResources/uk-UA/resources.resjson | 3 + stringResources/vi-VN/resources.resjson | 3 + stringResources/zh-CN/resources.resjson | 3 + stringResources/zh-TW/resources.resjson | 3 + 47 files changed, 137 insertions(+), 123 deletions(-) delete mode 100644 src/localization/localizationHelper.ts delete mode 100644 src/localization/localizedResources.ts create mode 100644 stringResources/ar-SA/resources.resjson create mode 100644 stringResources/bg-BG/resources.resjson create mode 100644 stringResources/ca-ES/resources.resjson create mode 100644 stringResources/cs-CZ/resources.resjson create mode 100644 stringResources/da-DK/resources.resjson create mode 100644 stringResources/de-DE/resources.resjson create mode 100644 stringResources/el-GR/resources.resjson create mode 100644 stringResources/en-US/resources.resjson create mode 100644 stringResources/es-ES/resources.resjson create mode 100644 stringResources/et-EE/resources.resjson create mode 100644 stringResources/eu-ES/resources.resjson create mode 100644 stringResources/fi-FI/resources.resjson create mode 100644 stringResources/fr-FR/resources.resjson create mode 100644 stringResources/gl-ES/resources.resjson create mode 100644 stringResources/he-IL/resources.resjson create mode 100644 stringResources/hi-IN/resources.resjson create mode 100644 stringResources/hr-HR/resources.resjson create mode 100644 stringResources/hu-HU/resources.resjson create mode 100644 stringResources/id-ID/resources.resjson create mode 100644 stringResources/it-IT/resources.resjson create mode 100644 stringResources/ja-JP/resources.resjson create mode 100644 stringResources/kk-KZ/resources.resjson create mode 100644 stringResources/ko-KR/resources.resjson create mode 100644 stringResources/lt-LT/resources.resjson create mode 100644 stringResources/lv-LV/resources.resjson create mode 100644 stringResources/ms-MY/resources.resjson create mode 100644 stringResources/nb-NO/resources.resjson create mode 100644 stringResources/nl-NL/resources.resjson create mode 100644 stringResources/pl-PL/resources.resjson create mode 100644 stringResources/pt-BR/resources.resjson create mode 100644 stringResources/pt-PT/resources.resjson create mode 100644 stringResources/ro-RO/resources.resjson create mode 100644 stringResources/ru-RU/resources.resjson create mode 100644 stringResources/sk-SK/resources.resjson create mode 100644 stringResources/sl-SI/resources.resjson create mode 100644 stringResources/sr-Cyrl-RS/resources.resjson create mode 100644 stringResources/sr-Latn-RS/resources.resjson create mode 100644 stringResources/sv-SE/resources.resjson create mode 100644 stringResources/th-TH/resources.resjson create mode 100644 stringResources/tr-TR/resources.resjson create mode 100644 stringResources/uk-UA/resources.resjson create mode 100644 stringResources/vi-VN/resources.resjson create mode 100644 stringResources/zh-CN/resources.resjson create mode 100644 stringResources/zh-TW/resources.resjson diff --git a/src/barChart.ts b/src/barChart.ts index 1f93d89..1d85284 100644 --- a/src/barChart.ts +++ b/src/barChart.ts @@ -23,7 +23,6 @@ import { import { dataViewObjects} from "powerbi-visuals-utils-dataviewutils"; import { BarChartSettingsModel } from "./barChartSettingsModel"; -import { getLocalizedString } from "./localization/localizationHelper" import "./../style/visual.less"; @@ -51,6 +50,7 @@ import VisualTooltipDataItem = powerbi.extensibility.VisualTooltipDataItem; import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions; import SubSelectionStylesType = powerbi.visuals.SubSelectionStylesType; import FormattingId = powerbi.visuals.FormattingId; +import ILocalizationManager = powerbi.extensibility.ILocalizationManager; /** @@ -286,6 +286,7 @@ export class BarChart implements IVisual { private tooltipServiceWrapper: ITooltipServiceWrapper; private xAxis: Selection; private barSelection: Selection; + private localizationManager: ILocalizationManager; private subSelectionHelper: HtmlSubSelectionHelper; private formatMode: boolean = false; @@ -327,8 +328,8 @@ export class BarChart implements IVisual { this.tooltipServiceWrapper = createTooltipServiceWrapper(this.host.tooltipService, options.element); //Creating the formatting settings service. - const localizationManager = this.host.createLocalizationManager(); - this.formattingSettingsService = new FormattingSettingsService(localizationManager); + this.localizationManager = this.host.createLocalizationManager(); + this.formattingSettingsService = new FormattingSettingsService(this.localizationManager); this.subSelectionHelper = HtmlSubSelectionHelper.createHtmlSubselectionHelper({ hostElement: options.element, @@ -837,7 +838,7 @@ export class BarChart implements IVisual { private getTooltipData(value: any): VisualTooltipDataItem[] { const formattedValue = valueFormatter.format(value.value, value.format); - const language = getLocalizedString(this.locale, "LanguageKey"); + const language = this.localizationManager.getDisplayName("LanguageKey"); return [{ displayName: value.category, value: formattedValue, diff --git a/src/localization/localizationHelper.ts b/src/localization/localizationHelper.ts deleted file mode 100644 index f751dff..0000000 --- a/src/localization/localizationHelper.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { localizedResources as myResources } from "./localizedResources"; - -export interface Localization { - "ar-SA": string; - "bg-BG": string; - "ca-ES": string; - "cs-CZ": string; - "da-DK": string; - "de-DE": string; - "el-GR": string; - "en-US": string; - "es-ES": string; - "et-EE": string; - "eU-ES": string; - "fi-FI": string; - "fr-FR": string; - "gl-ES": string; - "he-IL": string; - "hi-IN": string; - "hr-HR": string; - "hu-HU": string; - "id-ID": string; - "it-IT": string; - "ja-JP": string; - "kk-KZ": string; - "ko-KR": string; - "it-LT": string; - "lv-LV": string; - "ms-MY": string; - "nb-NO": string; - "nl-NL": string; - "pl-PL": string; - "pt-BR": string; - "pt-PT": string; - "ro-RO": string; - "ru-RU": string; - "sk-SK": string; - "sl-SI": string; - "sr-Cyrl-RS": string; - "sr-Latn-RS": string; - "sv-SE": string; - "th-TH": string; - "tr-TR": string; - "uk-UA": string; - "vi-VN": string; - "zh-CN": string; - "zh-TW": string; -} - -export interface LocalizaionResources { - defaultValue: string; - localization: Localization; -} - -export interface Resources { - [key: string]: LocalizaionResources; -} - -/** - * Returns the localized string in the locale transfared using the key that was given to serch the resources - * - * @param {string} locale - the locale in which PowerBI is currently running - * @param {object} key - specify a key for the string you want localized in your visual - */ -export function getLocalizedString(locale: string, key: string): string { - return myResources && key && myResources[key] && (((myResources[key]).localization[locale]) || (myResources[key]).defaultValue); -} diff --git a/src/localization/localizedResources.ts b/src/localization/localizedResources.ts deleted file mode 100644 index 306daaa..0000000 --- a/src/localization/localizedResources.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Resources } from "./localizationHelper"; - -export const localizedResources: Resources = {}; -localizedResources["LanguageKey"] = { - defaultValue: "English(English)", - localization: { - "ar-SA": "العربية (Arabic)", - "bg-BG": "български (Bulgarian)", - "ca-ES": "català (Catalan)", - "cs-CZ": "čeština (Czech)", - "da-DK": "dansk (Danish)", - "de-DE": "Deutsche (German)", - "el-GR": "ελληνικά (Greek)", - "en-US": "English (English)", - "es-ES": "español service (Spanish)", - "et-EE": "eesti (Estonian)", - "eU-ES": "Euskal (Basque)", - "fi-FI": "suomi (Finnish)", - "fr-FR": "français (French)", - "gl-ES": "galego (Galician)", - "he-IL": "עברית (Hebrew)", - "hi-IN": "हिन्दी (Hindi)", - "hr-HR": "hrvatski (Croatian)", - "hu-HU": "magyar (Hungarian)", - "id-ID": "Bahasa Indonesia (Indonesian)", - "it-IT": "italiano (Italian)", - "ja-JP": "日本の (Japanese)", - "kk-KZ": "Қазақ (Kazakh)", - "ko-KR": "한국의 (Korean)", - "it-LT": "Lietuvos (Lithuanian)", - "lv-LV": "Latvijas (Latvian)", - "ms-MY": "Bahasa Melayu (Malay)", - "nb-NO": "norsk (Norwegian)", - "nl-NL": "Nederlands (Dutch)", - "pl-PL": "polski (Polish)", - "pt-BR": "português (Portuguese)", - "pt-PT": "português (Portuguese)", - "ro-RO": "românesc (Romanian)", - "ru-RU": "русский (Russian)", - "sk-SK": "slovenský (Slovak)", - "sl-SI": "slovenski (Slovenian)", - "sr-Cyrl-RS": "српски (Serbian)", - "sr-Latn-RS": "srpski (Serbian)", - "sv-SE": "svenska (Swedish)", - "th-TH": "ไทย (Thai)", - "tr-TR": "Türk (Turkish)", - "uk-UA": "український (Ukrainian)", - "vi-VN": "tiếng Việt (Vietnamese)", - "zh-CN": "中国 (Chinese-Simplified)", - "zh-TW": "中國 (Chinese-Tranditional)" - } -}; diff --git a/stringResources/ar-SA/resources.resjson b/stringResources/ar-SA/resources.resjson new file mode 100644 index 0000000..fa53168 --- /dev/null +++ b/stringResources/ar-SA/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "العربية (Arabic)" +} \ No newline at end of file diff --git a/stringResources/bg-BG/resources.resjson b/stringResources/bg-BG/resources.resjson new file mode 100644 index 0000000..b9ac916 --- /dev/null +++ b/stringResources/bg-BG/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "български (Bulgarian)" +} \ No newline at end of file diff --git a/stringResources/ca-ES/resources.resjson b/stringResources/ca-ES/resources.resjson new file mode 100644 index 0000000..7a1e314 --- /dev/null +++ b/stringResources/ca-ES/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "català (Catalan)" +} \ No newline at end of file diff --git a/stringResources/cs-CZ/resources.resjson b/stringResources/cs-CZ/resources.resjson new file mode 100644 index 0000000..e9db3b5 --- /dev/null +++ b/stringResources/cs-CZ/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "čeština (Czech)" +} \ No newline at end of file diff --git a/stringResources/da-DK/resources.resjson b/stringResources/da-DK/resources.resjson new file mode 100644 index 0000000..9a3c986 --- /dev/null +++ b/stringResources/da-DK/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "dansk (Danish)" +} \ No newline at end of file diff --git a/stringResources/de-DE/resources.resjson b/stringResources/de-DE/resources.resjson new file mode 100644 index 0000000..7ae3382 --- /dev/null +++ b/stringResources/de-DE/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Deutsche (German)" +} \ No newline at end of file diff --git a/stringResources/el-GR/resources.resjson b/stringResources/el-GR/resources.resjson new file mode 100644 index 0000000..0ef29eb --- /dev/null +++ b/stringResources/el-GR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "ελληνικά (Greek)" +} \ No newline at end of file diff --git a/stringResources/en-US/resources.resjson b/stringResources/en-US/resources.resjson new file mode 100644 index 0000000..e5b1c03 --- /dev/null +++ b/stringResources/en-US/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "English (English)" +} diff --git a/stringResources/es-ES/resources.resjson b/stringResources/es-ES/resources.resjson new file mode 100644 index 0000000..6b4e139 --- /dev/null +++ b/stringResources/es-ES/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "español service (Spanish)" +} diff --git a/stringResources/et-EE/resources.resjson b/stringResources/et-EE/resources.resjson new file mode 100644 index 0000000..928f0e0 --- /dev/null +++ b/stringResources/et-EE/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "eesti (Estonian)" +} diff --git a/stringResources/eu-ES/resources.resjson b/stringResources/eu-ES/resources.resjson new file mode 100644 index 0000000..e48eeab --- /dev/null +++ b/stringResources/eu-ES/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Euskal (Basque)" +} diff --git a/stringResources/fi-FI/resources.resjson b/stringResources/fi-FI/resources.resjson new file mode 100644 index 0000000..fd6729d --- /dev/null +++ b/stringResources/fi-FI/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "suomi (Finnish)" +} diff --git a/stringResources/fr-FR/resources.resjson b/stringResources/fr-FR/resources.resjson new file mode 100644 index 0000000..99a9a30 --- /dev/null +++ b/stringResources/fr-FR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "français (French)" +} diff --git a/stringResources/gl-ES/resources.resjson b/stringResources/gl-ES/resources.resjson new file mode 100644 index 0000000..b6d02ed --- /dev/null +++ b/stringResources/gl-ES/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "galego (Galician)" +} diff --git a/stringResources/he-IL/resources.resjson b/stringResources/he-IL/resources.resjson new file mode 100644 index 0000000..796e4c0 --- /dev/null +++ b/stringResources/he-IL/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "עברית (Hebrew)" +} diff --git a/stringResources/hi-IN/resources.resjson b/stringResources/hi-IN/resources.resjson new file mode 100644 index 0000000..99bda7e --- /dev/null +++ b/stringResources/hi-IN/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "हिन्दी (Hindi)" +} diff --git a/stringResources/hr-HR/resources.resjson b/stringResources/hr-HR/resources.resjson new file mode 100644 index 0000000..8165c06 --- /dev/null +++ b/stringResources/hr-HR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "hrvatski (Croatian)" +} diff --git a/stringResources/hu-HU/resources.resjson b/stringResources/hu-HU/resources.resjson new file mode 100644 index 0000000..3d9e5c2 --- /dev/null +++ b/stringResources/hu-HU/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "magyar (Hungarian)" +} diff --git a/stringResources/id-ID/resources.resjson b/stringResources/id-ID/resources.resjson new file mode 100644 index 0000000..cfee31a --- /dev/null +++ b/stringResources/id-ID/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Bahasa Indonesia (Indonesian)" +} diff --git a/stringResources/it-IT/resources.resjson b/stringResources/it-IT/resources.resjson new file mode 100644 index 0000000..e4ca5c4 --- /dev/null +++ b/stringResources/it-IT/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "italiano (Italian)" +} diff --git a/stringResources/ja-JP/resources.resjson b/stringResources/ja-JP/resources.resjson new file mode 100644 index 0000000..bae187b --- /dev/null +++ b/stringResources/ja-JP/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "日本の (Japanese)" +} diff --git a/stringResources/kk-KZ/resources.resjson b/stringResources/kk-KZ/resources.resjson new file mode 100644 index 0000000..67d313f --- /dev/null +++ b/stringResources/kk-KZ/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Қазақ (Kazakh)" +} diff --git a/stringResources/ko-KR/resources.resjson b/stringResources/ko-KR/resources.resjson new file mode 100644 index 0000000..5833db5 --- /dev/null +++ b/stringResources/ko-KR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "한국의 (Korean)" +} diff --git a/stringResources/lt-LT/resources.resjson b/stringResources/lt-LT/resources.resjson new file mode 100644 index 0000000..a4ac12c --- /dev/null +++ b/stringResources/lt-LT/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Lietuvos (Lithuanian)" +} diff --git a/stringResources/lv-LV/resources.resjson b/stringResources/lv-LV/resources.resjson new file mode 100644 index 0000000..13ec7e5 --- /dev/null +++ b/stringResources/lv-LV/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Latvijas (Latvian)" +} diff --git a/stringResources/ms-MY/resources.resjson b/stringResources/ms-MY/resources.resjson new file mode 100644 index 0000000..89c302c --- /dev/null +++ b/stringResources/ms-MY/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Bahasa Melayu (Malay)" +} diff --git a/stringResources/nb-NO/resources.resjson b/stringResources/nb-NO/resources.resjson new file mode 100644 index 0000000..c615735 --- /dev/null +++ b/stringResources/nb-NO/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "norsk (Norwegian)" +} diff --git a/stringResources/nl-NL/resources.resjson b/stringResources/nl-NL/resources.resjson new file mode 100644 index 0000000..6b73512 --- /dev/null +++ b/stringResources/nl-NL/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Nederlands (Dutch)" +} diff --git a/stringResources/pl-PL/resources.resjson b/stringResources/pl-PL/resources.resjson new file mode 100644 index 0000000..66806f0 --- /dev/null +++ b/stringResources/pl-PL/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "polski (Polish)" +} diff --git a/stringResources/pt-BR/resources.resjson b/stringResources/pt-BR/resources.resjson new file mode 100644 index 0000000..7cf29d0 --- /dev/null +++ b/stringResources/pt-BR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "português (Portuguese)" +} diff --git a/stringResources/pt-PT/resources.resjson b/stringResources/pt-PT/resources.resjson new file mode 100644 index 0000000..7cf29d0 --- /dev/null +++ b/stringResources/pt-PT/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "português (Portuguese)" +} diff --git a/stringResources/ro-RO/resources.resjson b/stringResources/ro-RO/resources.resjson new file mode 100644 index 0000000..e983246 --- /dev/null +++ b/stringResources/ro-RO/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "românesc (Romanian)" +} diff --git a/stringResources/ru-RU/resources.resjson b/stringResources/ru-RU/resources.resjson new file mode 100644 index 0000000..e4c095e --- /dev/null +++ b/stringResources/ru-RU/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "русский (Russian)" +} diff --git a/stringResources/sk-SK/resources.resjson b/stringResources/sk-SK/resources.resjson new file mode 100644 index 0000000..3d76048 --- /dev/null +++ b/stringResources/sk-SK/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "slovenský (Slovak)" +} diff --git a/stringResources/sl-SI/resources.resjson b/stringResources/sl-SI/resources.resjson new file mode 100644 index 0000000..71c1e13 --- /dev/null +++ b/stringResources/sl-SI/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "slovenski (Slovenian)" +} diff --git a/stringResources/sr-Cyrl-RS/resources.resjson b/stringResources/sr-Cyrl-RS/resources.resjson new file mode 100644 index 0000000..0c47da0 --- /dev/null +++ b/stringResources/sr-Cyrl-RS/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "српски (Serbian)" +} diff --git a/stringResources/sr-Latn-RS/resources.resjson b/stringResources/sr-Latn-RS/resources.resjson new file mode 100644 index 0000000..db40811 --- /dev/null +++ b/stringResources/sr-Latn-RS/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "srpski (Serbian)" +} diff --git a/stringResources/sv-SE/resources.resjson b/stringResources/sv-SE/resources.resjson new file mode 100644 index 0000000..246f02a --- /dev/null +++ b/stringResources/sv-SE/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "svenska (Swedish)" +} diff --git a/stringResources/th-TH/resources.resjson b/stringResources/th-TH/resources.resjson new file mode 100644 index 0000000..53a507c --- /dev/null +++ b/stringResources/th-TH/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "ไทย (Thai)" +} diff --git a/stringResources/tr-TR/resources.resjson b/stringResources/tr-TR/resources.resjson new file mode 100644 index 0000000..b45efe0 --- /dev/null +++ b/stringResources/tr-TR/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "Türk (Turkish)" +} diff --git a/stringResources/uk-UA/resources.resjson b/stringResources/uk-UA/resources.resjson new file mode 100644 index 0000000..d6ceeb5 --- /dev/null +++ b/stringResources/uk-UA/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "український (Ukrainian)" +} diff --git a/stringResources/vi-VN/resources.resjson b/stringResources/vi-VN/resources.resjson new file mode 100644 index 0000000..2dcf6ae --- /dev/null +++ b/stringResources/vi-VN/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "tiếng Việt (Vietnamese)" +} diff --git a/stringResources/zh-CN/resources.resjson b/stringResources/zh-CN/resources.resjson new file mode 100644 index 0000000..d1a93f2 --- /dev/null +++ b/stringResources/zh-CN/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "中国 (Chinese-Simplified)" +} diff --git a/stringResources/zh-TW/resources.resjson b/stringResources/zh-TW/resources.resjson new file mode 100644 index 0000000..da6e52f --- /dev/null +++ b/stringResources/zh-TW/resources.resjson @@ -0,0 +1,3 @@ +{ + "LanguageKey": "中國 (Chinese-Tranditional)" +} From 161ebe1e3e781960b21c25b1cfaac03ebae7969a Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Wed, 24 Apr 2024 11:50:10 +0200 Subject: [PATCH 5/8] Fix lint error --- src/barChart.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/barChart.ts b/src/barChart.ts index 1d85284..c07d700 100644 --- a/src/barChart.ts +++ b/src/barChart.ts @@ -31,7 +31,6 @@ type Selection = d3Selection; // powerbi.visuals import CustomVisualSubSelection = powerbi.visuals.CustomVisualSubSelection; import DataViewCategoryColumn = powerbi.DataViewCategoryColumn; -import DataViewObjects = powerbi.DataViewObjects; import Fill = powerbi.Fill; import ISandboxExtendedColorPalette = powerbi.extensibility.ISandboxExtendedColorPalette; import ISelectionId = powerbi.visuals.ISelectionId; From 1d5389cd5747ae02f0928123ae89bfcfdaa2f215 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Wed, 24 Apr 2024 12:46:40 +0200 Subject: [PATCH 6/8] Replace ItemDropdown with AutoDropdown --- capabilities.json | 11 ++++++++++- src/barChart.ts | 2 +- src/barChartSettingsModel.ts | 8 +++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/capabilities.json b/capabilities.json index afd5211..1d950a7 100644 --- a/capabilities.json +++ b/capabilities.json @@ -137,7 +137,16 @@ }, "position": { "type": { - "enumeration": [] + "enumeration": [ + { + "value": "Left", + "displayName": "Left" + }, + { + "value": "Right", + "displayName": "Right" + } + ] } } } diff --git a/src/barChart.ts b/src/barChart.ts index c07d700..2dd97f7 100644 --- a/src/barChart.ts +++ b/src/barChart.ts @@ -510,7 +510,7 @@ export class BarChart implements IVisual { .style("font-style", this.formattingSettings.directEditSettings.font.italic.value ? "italic" : "normal") .style("text-decoration", this.formattingSettings.directEditSettings.font.underline.value ? "underline" : "none") .style("font-weight", this.formattingSettings.directEditSettings.font.bold.value ? "bold" : "normal") - .style("right", this.formattingSettings.directEditSettings.position.value.value === "Right" ? "12px" : "60px") + .style("right", this.formattingSettings.directEditSettings.position.value === "Right" ? "12px" : "60px") .style("background-color", this.formattingSettings.directEditSettings.background.value.value) .style("font-size", `${this.formattingSettings.directEditSettings.font.fontSize.value}px`) .text(this.formattingSettings.directEditSettings.textProperty.value); diff --git a/src/barChartSettingsModel.ts b/src/barChartSettingsModel.ts index b42501c..ba01e91 100644 --- a/src/barChartSettingsModel.ts +++ b/src/barChartSettingsModel.ts @@ -9,7 +9,7 @@ import ColorPicker = formattingSettings.ColorPicker; import ToggleSwitch = formattingSettings.ToggleSwitch; import NumUpDown = formattingSettings.NumUpDown; import TextInput = formattingSettings.TextInput; -import ItemDropdown = formattingSettings.ItemDropdown; +import AutoDropdown = formattingSettings.AutoDropdown; import FontControl = formattingSettings.FontControl; import FontPicker = formattingSettings.FontPicker; @@ -98,7 +98,6 @@ class DirectEditSettings extends Card { name: string = "directEdit"; private minFontSize: number = 8; private defaultFontSize: number = 11; - private positionOptions: powerbiVisualsApi.IEnumMember[] = [{ displayName: "Right", value: "Right" }, { displayName: "Left", value: "Left" }] show = new ToggleSwitch({ name: "show", displayName: undefined, @@ -113,11 +112,10 @@ class DirectEditSettings extends Card { placeholder: "" }); - position = new ItemDropdown({ + position = new AutoDropdown({ name: "position", displayName: "Position", - items: this.positionOptions, - value: this.positionOptions[0] + value: "Right" }); font = new FontControl({ From 4fe7e43912b3c5ae267418ccbe05fbccc9c1ee83 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Wed, 24 Apr 2024 12:50:28 +0200 Subject: [PATCH 7/8] Increment visual version --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 4 ++-- package.json | 2 +- pbiviz.json | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5873631..21e1f0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ This page contains information about changes to the 'Sample bar chart' Power BI visual. +## 4.1.1.0 + +* Added localizationManager +* Replaced objectEnumerationUtility with dataviewUtils + +## 4.1.0.0 + +* Added onObject support +* Added formatting model + ## 4.0.0 * Added *dynamic format* feature support diff --git a/package-lock.json b/package-lock.json index 7cb48ea..6be97c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "visual", - "version": "4.0.0", + "version": "4.1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "visual", - "version": "4.0.0", + "version": "4.1.1.0", "dependencies": { "powerbi-visuals-utils-onobjectutils": "^6.0.1" }, diff --git a/package.json b/package.json index e68d8b5..0f24de9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "visual", - "version": "4.1.0.0", + "version": "4.1.1.0", "scripts": { "pbiviz": "pbiviz", "start": "pbiviz start", diff --git a/pbiviz.json b/pbiviz.json index 06ac37d..ca541e7 100644 --- a/pbiviz.json +++ b/pbiviz.json @@ -4,7 +4,7 @@ "displayName": "barChart", "guid": "PBI_CV_9894B302_1DFF_4A96_ABFE_BF8588197166", "visualClassName": "BarChart", - "version": "4.1.0.0", + "version": "4.1.1.0", "description": "Sample bar chart", "supportUrl": "pbicvsupport@microsoft.com", "gitHubUrl": "" From 5449b6bf616c9ba5f8a5c78136aa69207dc6ced7 Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Wed, 24 Apr 2024 16:04:21 +0200 Subject: [PATCH 8/8] Update codeQl --- .github/workflows/codeql-analysis.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 97fee86..bec0506 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,28 +18,43 @@ on: # The branches below must be a subset of the branches above branches: [ main ] schedule: - - cron: '20 13 * * 2' + - cron: '0 0 * * 3' jobs: analyze: name: Analyze runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + actions: read + contents: read + security-events: write strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: [ 'typescript' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Use Node.js 18 + uses: actions/setup-node@v2 + with: + node-version: 18.x + + - name: Install Dependencies + run: npm ci # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,7 +65,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -64,4 +79,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3