X axis type option works correctly now (#6)
This commit is contained in:
Родитель
29bf060375
Коммит
3d819d0147
|
@ -1,3 +1,7 @@
|
|||
## 3.1.0
|
||||
* API 2.5.0
|
||||
* Pop-up chart X Axis type option now works and apply this changes to Sparklines too
|
||||
|
||||
## 3.0.0
|
||||
* API 2.3.0
|
||||
* Webpack based PBIVIZ
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "powerbi-visuals-powerkpimatrix",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"description": "Monitor balanced scorecards and unlimited number of metrics and KPIs in a single, compact, easy to read list.",
|
||||
"scripts": {
|
||||
"start": "pbiviz start",
|
||||
|
@ -51,10 +51,10 @@
|
|||
"less": "^3.9.0",
|
||||
"less-loader": "^4.1.0",
|
||||
"mini-css-extract-plugin": "^0.5.0",
|
||||
"powerbi-visuals-api": "2.2.2",
|
||||
"powerbi-visuals-powerkpi": "git@github.com:Microsoft/PowerBI-visuals-PowerKPI.git",
|
||||
"powerbi-visuals-api": "^2.5.0",
|
||||
"powerbi-visuals-powerkpi": "https://github.com/microsoft/PowerBI-visuals-PowerKPI",
|
||||
"powerbi-visuals-tools": "^3.0.9",
|
||||
"powerbi-visuals-utils-testutils": "^2.1.4",
|
||||
"powerbi-visuals-utils-testutils": "^2.2.0",
|
||||
"puppeteer": "^1.11.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"ts-loader": "^5.3.3",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"visual": {
|
||||
"name": "PowerKPIMatrix",
|
||||
"displayName": "Power KPI Matrix 3.0.0",
|
||||
"displayName": "Power KPI Matrix 3.1.0",
|
||||
"guid": "powerKPIMatrixEB2381CC88A8425FBEB1B07FF57784E6",
|
||||
"visualClassName": "PowerKPIMatrix",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"description": "Monitor balanced scorecards and unlimited number of metrics and KPIs in a single, compact, easy to read list.",
|
||||
"supportUrl": "https://aka.ms/customvisualscommunity",
|
||||
"gitHubUrl": "https://github.com/Microsoft/PowerBI-visuals-PowerKPIMatrix"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Power BI Visualizations
|
||||
*
|
||||
* Copyright (c) Microsoft Corporation
|
||||
* All rights reserved.
|
||||
* MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the ""Software""), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
import powerbi from "powerbi-visuals-api";
|
||||
|
||||
import { DataBuilder, DataViewType } from "./dataBuilder";
|
||||
|
||||
export class ColumnBaseDataBuilderWithgAxisTypeAdaptedData extends DataBuilder {
|
||||
constructor() {
|
||||
super(0, 1, DataViewType.CATEGORICAL_CONTINUOUS_SAMPLE);
|
||||
}
|
||||
|
||||
public getDataView(columnNames?: string[]): powerbi.DataView {
|
||||
return this.getDataViewCore(columnNames, []);
|
||||
}
|
||||
}
|
|
@ -23,45 +23,33 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import "jasmine-jquery";
|
||||
|
||||
import { select as d3Select, Selection as ID3Selection } from "d3-selection";
|
||||
import powerbi from "powerbi-visuals-api";
|
||||
import { MockISelectionIdBuilder, testDom } from "powerbi-visuals-utils-testutils";
|
||||
|
||||
import {
|
||||
select as d3Select,
|
||||
Selection as ID3Selection,
|
||||
} from "d3-selection";
|
||||
|
||||
ColumnBasedModelConverter,
|
||||
} from "../src/converter/data/columnBasedModel/columnBasedModelConverter";
|
||||
import { DataConverter } from "../src/converter/data/dataConverter";
|
||||
import {
|
||||
MockISelectionIdBuilder,
|
||||
testDom,
|
||||
} from "powerbi-visuals-utils-testutils";
|
||||
|
||||
IDataRepresentationSeries,
|
||||
} from "../src/converter/data/dataRepresentation/dataRepresentationSeries";
|
||||
import {
|
||||
IKPIIndicatorSettings,
|
||||
KPIIndicatorSettings,
|
||||
} from "../src/settings/descriptors/kpi/kpiIndicatorSettings";
|
||||
|
||||
import { ColumnBasedModelConverter } from "../src/converter/data/columnBasedModel/columnBasedModelConverter";
|
||||
IDataRepresentationSeriesSet,
|
||||
} from "../src/converter/data/dataRepresentation/dataRepresentationSeriesSet";
|
||||
import { RowBasedModelConverter } from "../src/converter/data/rowBasedModel/rowBasedModelConverter";
|
||||
|
||||
import { ModalWindowService } from "../src/services/modalWindowService";
|
||||
import { ScaleService } from "../src/services/scaleService";
|
||||
import { SettingsState } from "../src/services/state/settingsState";
|
||||
|
||||
import { IDataRepresentationSeries } from "../src/converter/data/dataRepresentation/dataRepresentationSeries";
|
||||
import { IDataRepresentationSeriesSet } from "../src/converter/data/dataRepresentation/dataRepresentationSeriesSet";
|
||||
|
||||
import {
|
||||
IKPIIndicatorSettings, KPIIndicatorSettings,
|
||||
} from "../src/settings/descriptors/kpi/kpiIndicatorSettings";
|
||||
import { Settings } from "../src/settings/settings";
|
||||
|
||||
import { LazyComponent } from "../src/visualComponent/lazyComponent";
|
||||
import { IVisualComponent } from "../src/visualComponent/visualComponent";
|
||||
|
||||
import { ColumnBasedDataBuilder } from "./columnBasedDataBuilder";
|
||||
import { DataBuilder } from "./dataBuilder";
|
||||
import { TestWrapper } from "./testWrapper";
|
||||
import { VisualBuilder } from "./visualBuilder";
|
||||
|
||||
describe("Power KPI Matrix", () => {
|
||||
describe("static", () => {
|
||||
|
@ -79,6 +67,34 @@ describe("Power KPI Matrix", () => {
|
|||
testWrapper = TestWrapper.createWithColumnBasedData();
|
||||
});
|
||||
|
||||
it("X axis is continuous", (done) => {
|
||||
const continuousPath: string = "M2.8,15.686956521739134L72.43478260869566,52.2L92.3304347826087,2.799999999999997L97" +
|
||||
".30434782608695,15.686956521739134L102.27826086956522,17.834782608695654L117.2,15.686956521739134";
|
||||
testWrapper = TestWrapper.createWithColumnBasedAndAxisTypeAdaptedData();
|
||||
testWrapper.visualBuilder.updateRenderTimeout(testWrapper.dataView, () => {
|
||||
const linePathData = testWrapper.visualBuilder.$linePath.attr("d");
|
||||
expect(linePathData).toEqual(continuousPath);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("X axis is categorical", (done) => {
|
||||
const categoricalPath: string = "M2.8,15.686956521739134L25.680000000000003,52.2L48.56,2.799999999999997L71" +
|
||||
".44000000000001,15.686956521739134L94.32000000000001,17.834782608695654L117.2,15.686956521739134";
|
||||
testWrapper = TestWrapper.createWithColumnBasedAndAxisTypeAdaptedData();
|
||||
testWrapper.dataView.metadata.objects = {
|
||||
integratedPowerKPI_xAxis: {
|
||||
type: 1,
|
||||
},
|
||||
};
|
||||
|
||||
testWrapper.visualBuilder.updateRenderTimeout(testWrapper.dataView, () => {
|
||||
const linePathData = testWrapper.visualBuilder.$linePath.attr("d");
|
||||
expect(linePathData).toEqual(categoricalPath);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("root element should be defined in DOM", (done) => {
|
||||
testWrapper.visualBuilder.updateRenderTimeout(testWrapper.dataView, () => {
|
||||
expect(testWrapper.visualBuilder.$root).toBeInDOM();
|
||||
|
|
|
@ -47,6 +47,11 @@ interface IValuesSet {
|
|||
[columnName: string]: number[][];
|
||||
}
|
||||
|
||||
export enum DataViewType {
|
||||
DEFAULT,
|
||||
CATEGORICAL_CONTINUOUS_SAMPLE,
|
||||
}
|
||||
|
||||
export abstract class DataBuilder extends testDataViewBuilder.TestDataViewBuilder {
|
||||
public dates: Date[];
|
||||
public values: IValuesSet = {};
|
||||
|
@ -70,25 +75,49 @@ export abstract class DataBuilder extends testDataViewBuilder.TestDataViewBuilde
|
|||
},
|
||||
];
|
||||
|
||||
constructor(amountOfValues: number, amountOfSeries: number) {
|
||||
constructor(amountOfValues: number, amountOfSeries: number, caseType: DataViewType = DataViewType.DEFAULT) {
|
||||
super();
|
||||
|
||||
this.amountOfValues = amountOfValues;
|
||||
this.amountOfSeries = amountOfSeries;
|
||||
if (caseType === DataViewType.CATEGORICAL_CONTINUOUS_SAMPLE) {
|
||||
this.amountOfValues = 28;
|
||||
this.amountOfSeries = 1;
|
||||
|
||||
const endDate: Date = new Date(1970, 0, 1);
|
||||
const endDate: Date = new Date(2019, 3, 12);
|
||||
|
||||
endDate.setDate(endDate.getDate() + this.amountOfValues);
|
||||
endDate.setDate(endDate.getDate() + this.amountOfValues);
|
||||
|
||||
this.dates = getDateRange(
|
||||
new Date(1970, 0, 1),
|
||||
endDate,
|
||||
8.64e+7,
|
||||
);
|
||||
this.dates = [
|
||||
new Date(2019, 3, 14),
|
||||
new Date(2019, 3, 28),
|
||||
new Date(2019, 4, 2),
|
||||
new Date(2019, 4, 3),
|
||||
new Date(2019, 4, 4),
|
||||
new Date(2019, 4, 7),
|
||||
];
|
||||
|
||||
this.columns.forEach((column: IColumnDefinition) => {
|
||||
this.values[column.column.name] = this.getRandomValuesSet(column.max, column.max);
|
||||
});
|
||||
const activeValuesSet: number[][] = [[57, 6, 75, 57, 54, 57]];
|
||||
|
||||
this.values[actualValueColumn.name] = activeValuesSet;
|
||||
this.values[comparisonValueColumn.name] = this.getRandomValuesSet(-99999999, 99999999);
|
||||
this.values[kpiIndicatorIndexColumn.name] = this.getRandomValuesSet(-99999999, 99999999);
|
||||
} else {
|
||||
this.amountOfValues = amountOfValues;
|
||||
this.amountOfSeries = amountOfSeries;
|
||||
|
||||
const endDate: Date = new Date(1970, 0, 1);
|
||||
|
||||
endDate.setDate(endDate.getDate() + this.amountOfValues);
|
||||
|
||||
this.dates = getDateRange(
|
||||
new Date(1970, 0, 1),
|
||||
endDate,
|
||||
8.64e+7,
|
||||
);
|
||||
|
||||
this.columns.forEach((column: IColumnDefinition) => {
|
||||
this.values[column.column.name] = this.getRandomValuesSet(column.max, column.max);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected getRandomValuesSet(min: number, max: number): number[][] {
|
||||
|
|
|
@ -23,9 +23,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import powerbi from "powerbi-visuals-api";
|
||||
|
||||
import {
|
||||
ColumnBaseDataBuilderWithgAxisTypeAdaptedData,
|
||||
} from "./columnBaseDataBuilderWithgAxisTypeAdaptedData";
|
||||
import { ColumnBasedDataBuilder } from "./columnBasedDataBuilder";
|
||||
import { DataBuilder } from "./dataBuilder";
|
||||
import { VisualBuilder } from "./visualBuilder";
|
||||
|
@ -35,6 +37,10 @@ export class TestWrapper {
|
|||
return new TestWrapper(new ColumnBasedDataBuilder());
|
||||
}
|
||||
|
||||
public static createWithColumnBasedAndAxisTypeAdaptedData(): TestWrapper {
|
||||
return new TestWrapper(new ColumnBaseDataBuilderWithgAxisTypeAdaptedData());
|
||||
}
|
||||
|
||||
public dataView: powerbi.DataView;
|
||||
public dataViewBuilder: DataBuilder;
|
||||
public visualBuilder: VisualBuilder;
|
||||
|
|
|
@ -47,4 +47,8 @@ export class VisualBuilder extends VisualBuilderBase<PowerKPIMatrix> {
|
|||
public get $cells(): JQuery {
|
||||
return this.$root.find(".cellComponent");
|
||||
}
|
||||
|
||||
public get $linePath(): JQuery {
|
||||
return this.$root.find(".lineComponent_line");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,47 +23,8 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import powerbi from "powerbi-visuals-api";
|
||||
|
||||
import { IDataRepresentationColumnMapping } from "../columnMapping/dataRepresentation/dataRepresentationColumnMapping";
|
||||
import { IDataRepresentation } from "./dataRepresentation/dataRepresentation";
|
||||
|
||||
import {
|
||||
IDataRepresentationAxis,
|
||||
IDataRepresentationAxisWithScale,
|
||||
} from "./dataRepresentation/dataRepresentationAxis";
|
||||
|
||||
import { DataRepresentationAxisValueType } from "./dataRepresentation/dataRepresentationAxisValueType";
|
||||
import { IDataRepresentationColumns } from "./dataRepresentation/dataRepresentationColumns";
|
||||
import { DataRepresentationScale } from "./dataRepresentation/dataRepresentationScale";
|
||||
import { IDataRepresentationSeries } from "./dataRepresentation/dataRepresentationSeries";
|
||||
import { IDataRepresentationSeriesSet } from "./dataRepresentation/dataRepresentationSeriesSet";
|
||||
import { DataRepresentationSeriesUtils } from "./dataRepresentation/dataRepresentationSeriesUtils";
|
||||
import { DataRepresentationTypeEnum } from "./dataRepresentation/dataRepresentationType";
|
||||
|
||||
import { NumericValueUtils } from "../../utils/numericValueUtils";
|
||||
|
||||
import { SettingsState } from "../../services/state/settingsState";
|
||||
|
||||
import {
|
||||
SubtotalSettings,
|
||||
SubtotalType,
|
||||
} from "../../settings/descriptors/subtotalSettings";
|
||||
|
||||
import { IKPIIndicatorSettings } from "../../settings/descriptors/kpi/kpiIndicatorSettings";
|
||||
import { NumberSettingsBase } from "../../settings/descriptors/numberSettingsBase";
|
||||
import { LineStyle } from "../../settings/descriptors/sparklineSettings";
|
||||
|
||||
import { SettingsPropertyBase } from "../../settings/descriptors/settingsPropertyBase";
|
||||
import { TableStyle } from "../../settings/descriptors/tableSettings";
|
||||
|
||||
import { SeriesSettings } from "../../settings/seriesSettings";
|
||||
import { Settings } from "../../settings/settings";
|
||||
|
||||
import { IConverter } from "../converter";
|
||||
import { IConverterOptions } from "../converterOptions";
|
||||
import { VarianceStrategy } from "./variance/varianceStrategy";
|
||||
import { AxisType } from "powerbi-visuals-powerkpi/src/settings/descriptors/axis/axisDescriptor";
|
||||
|
||||
import { actualValueColumn } from "../../columns/actualValueColumn";
|
||||
import { categoryColumn } from "../../columns/categoryColumn";
|
||||
|
@ -75,7 +36,36 @@ import { kpiIndicatorValueColumn } from "../../columns/kpiIndicatorValueColumn";
|
|||
import { secondComparisonValueColumn } from "../../columns/secondComparisonValueColumn";
|
||||
import { sortOrderColumn } from "../../columns/sortOrderColumn";
|
||||
import { IVisualDataColumn } from "../../columns/visualDataColumn";
|
||||
import { SettingsState } from "../../services/state/settingsState";
|
||||
import { IKPIIndicatorSettings } from "../../settings/descriptors/kpi/kpiIndicatorSettings";
|
||||
import { NumberSettingsBase } from "../../settings/descriptors/numberSettingsBase";
|
||||
import { SettingsPropertyBase } from "../../settings/descriptors/settingsPropertyBase";
|
||||
import { LineStyle } from "../../settings/descriptors/sparklineSettings";
|
||||
import { SubtotalSettings, SubtotalType } from "../../settings/descriptors/subtotalSettings";
|
||||
import { TableStyle } from "../../settings/descriptors/tableSettings";
|
||||
import { SeriesSettings } from "../../settings/seriesSettings";
|
||||
import { Settings } from "../../settings/settings";
|
||||
import { NumericValueUtils } from "../../utils/numericValueUtils";
|
||||
import {
|
||||
IDataRepresentationColumnMapping,
|
||||
} from "../columnMapping/dataRepresentation/dataRepresentationColumnMapping";
|
||||
import { IConverter } from "../converter";
|
||||
import { IConverterOptions } from "../converterOptions";
|
||||
import { IDataRepresentation } from "./dataRepresentation/dataRepresentation";
|
||||
import {
|
||||
IDataRepresentationAxis, IDataRepresentationAxisWithScale,
|
||||
} from "./dataRepresentation/dataRepresentationAxis";
|
||||
import {
|
||||
DataRepresentationAxisValueType,
|
||||
} from "./dataRepresentation/dataRepresentationAxisValueType";
|
||||
import { IDataRepresentationColumns } from "./dataRepresentation/dataRepresentationColumns";
|
||||
import { IDataRepresentationPointSet } from "./dataRepresentation/dataRepresentationPointSet";
|
||||
import { DataRepresentationScale } from "./dataRepresentation/dataRepresentationScale";
|
||||
import { IDataRepresentationSeries } from "./dataRepresentation/dataRepresentationSeries";
|
||||
import { IDataRepresentationSeriesSet } from "./dataRepresentation/dataRepresentationSeriesSet";
|
||||
import { DataRepresentationSeriesUtils } from "./dataRepresentation/dataRepresentationSeriesUtils";
|
||||
import { DataRepresentationTypeEnum } from "./dataRepresentation/dataRepresentationType";
|
||||
import { VarianceStrategy } from "./variance/varianceStrategy";
|
||||
|
||||
export interface IHyperlinkSet {
|
||||
[metricName: string]: string;
|
||||
|
@ -134,7 +124,7 @@ export interface ICurrentSeriesData {
|
|||
export interface IConverterStepOptions {
|
||||
dataRepresentation: IDataRepresentation;
|
||||
columnValues: IColumnValues;
|
||||
identities: powerbi.data.DataRepetitionSelector[]; // TODO: it used to be DataViewScopeIdentity
|
||||
identities: powerbi.visuals.CustomVisualOpaqueIdentity[];
|
||||
identityQueryName: string;
|
||||
columnMapping: IDataRepresentationColumnMapping;
|
||||
rows: powerbi.DataViewTableRow[];
|
||||
|
@ -230,7 +220,7 @@ export abstract class DataConverter implements IConverter<IDataRepresentation> {
|
|||
secondComparisonValueColumn,
|
||||
]);
|
||||
|
||||
dataRepresentation.type = this.getTypeOfColumn(xAxisMetadataColumn);
|
||||
dataRepresentation.type = this.getTypeOfColumn(xAxisMetadataColumn, settings.powerKPISettings.xAxis.type);
|
||||
dataRepresentation.metadata = xAxisMetadataColumn;
|
||||
|
||||
settings.asOfDate.parseByType(dataRepresentation.type);
|
||||
|
@ -352,14 +342,14 @@ export abstract class DataConverter implements IConverter<IDataRepresentation> {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
protected getTypeOfColumn(column: powerbi.DataViewMetadataColumn): DataRepresentationTypeEnum {
|
||||
protected getTypeOfColumn(column: powerbi.DataViewMetadataColumn, forcedXAxisType: AxisType): DataRepresentationTypeEnum {
|
||||
if (column) {
|
||||
if (column.type.dateTime) {
|
||||
if (column.type.text || forcedXAxisType === AxisType.categorical) {
|
||||
return DataRepresentationTypeEnum.StringType;
|
||||
} else if (column.type.dateTime) {
|
||||
return DataRepresentationTypeEnum.DateType;
|
||||
} else if (column.type.integer || column.type.numeric) {
|
||||
return DataRepresentationTypeEnum.NumberType;
|
||||
} else if (column.type.text) {
|
||||
return DataRepresentationTypeEnum.StringType;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,7 +685,7 @@ export abstract class DataConverter implements IConverter<IDataRepresentation> {
|
|||
seriesArray: IDataRepresentationSeries[],
|
||||
levels: string[],
|
||||
displayName: string,
|
||||
identities: powerbi.data.DataRepetitionSelector[],
|
||||
identities: powerbi.visuals.CustomVisualOpaqueIdentity[],
|
||||
identityIndex: number,
|
||||
identityQueryName: string,
|
||||
rows: powerbi.DataViewTableRow[],
|
||||
|
|
Загрузка…
Ссылка в новой задаче