13726 “NPM packages: Update source code of the Radar visual in order to support the new packages”

This commit is contained in:
Ignat Vilesov 2016-12-21 21:21:05 +03:00
Родитель 2409e46826
Коммит c9a723a5b5
11 изменённых файлов: 400 добавлений и 192 удалений

25
LICENSE Normal file
Просмотреть файл

@ -0,0 +1,25 @@
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.

Просмотреть файл

@ -1,16 +1,18 @@
{
"name": "powerbi-visuals-radarchart",
"description": "A simple radar chart supporting multiple measures plotted over a categorical axis. Also known as a web chart, spider chart, or star chart. Use to display performance metrics for quality improvement.",
"version": "0.5.5",
"version": "0.5.6",
"author": {
"name": "Microsoft",
"email": "pbicvsupport@microsoft.com"
},
"scripts": {
"postinstall": "typings install && pbiviz update 1.2.0",
"typings": "node node_modules/typings/dist/bin.js i",
"pbiviz": "node node_modules/powerbi-visuals-tools/bin/pbiviz.js",
"lint": "node node_modules/tslint/bin/tslint \"src/**/*.ts\""
"postinstall": "typings install && pbiviz update 1.3.0",
"typings": "typings",
"pbiviz": "pbiviz",
"start": "pbiviz start",
"package": "pbiviz package",
"lint": "node node_modules/tslint/bin/tslint \"+(src|test)/**/*.ts\""
},
"license": "MIT",
"repository": {
@ -18,44 +20,14 @@
"url": "git+https://github.com/Microsoft/PowerBI-visuals-RadarChart.git"
},
"devDependencies": {
"@powerbi-visuals-utils/colorhelper": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-colorhelper.git",
"@powerbi-visuals-utils/controls-touchutils": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-controls-touchutils.git",
"@powerbi-visuals-utils/cssconstants": "git+https://github.com/uve/powerbi-visuals-utils-cssconstants.git",
"@powerbi-visuals-utils/dataLabelManager": "git+https://github.com/vtkalek/powerbi-visuals-utils-datalabelmanager.git",
"@powerbi-visuals-utils/datacolorpalette": "git+https://github.com/vtkalek/powerbi-visuals-utils-datacolorpalette.git",
"@powerbi-visuals-utils/datalabelutils": "git+https://github.com/vtkalek/powerbi-visuals-utils-datalabelutils.git",
"@powerbi-visuals-utils/displayunitsystem": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-displayunitsystem.git",
"@powerbi-visuals-utils/displayunitsystemtype": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-displayunitsystemtype.git",
"@powerbi-visuals-utils/external-loader": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-external-loader.git",
"@powerbi-visuals-utils/fontutils": "git+https://github.com/vtkalek/powerbi-visuals-utils-fontutils.git",
"@powerbi-visuals-utils/formatting": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-formatting.git",
"@powerbi-visuals-utils/formattingservice": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-formattingservice.git",
"@powerbi-visuals-utils/imargin": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-imargin.git",
"@powerbi-visuals-utils/interactivityservice": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-interactivityservice.git",
"@powerbi-visuals-utils/interactivityutils": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-interactivityutils.git",
"@powerbi-visuals-utils/legend": "git+https://github.com/vtkalek/powerbi-visuals-utils-legend.git",
"@powerbi-visuals-utils/localstorageservice": "git+https://github.com/uve/powerbi-visuals-utils-localstorageservice.git",
"@powerbi-visuals-utils/pixelconverter": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-pixelconverter.git",
"@powerbi-visuals-utils/point": "git+https://github.com/vtkalek/powerbi-visuals-utils-point.git",
"@powerbi-visuals-utils/pointerutils": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-pointerutils.git",
"@powerbi-visuals-utils/rect": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-rect.git",
"@powerbi-visuals-utils/shapes": "git+https://github.com/vtkalek/powerbi-visuals-utils-shapes.git",
"@powerbi-visuals-utils/standaloneutility": "git+https://github.com/vtkalek/powerbi-visuals-utils-standaloneutility.git",
"@powerbi-visuals-utils/stringextensions": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-stringextensions.git",
"@powerbi-visuals-utils/svgutil": "git+https://github.com/vtkalek/powerbi-visuals-utils-svgutil.git",
"@powerbi-visuals-utils/textmeasurementservice": "git+https://github.com/uve/powerbi-visuals-utils-textmeasurementservice.git",
"@powerbi-visuals-utils/tooltipbuilder": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-tooltipbuilder.git",
"@powerbi-visuals-utils/tooltipmanager": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-tooltipmanager.git",
"@powerbi-visuals-utils/tooltipservice": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-tooltipservice.git",
"@powerbi-visuals-utils/valueformatter": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-valueformatter.git",
"@powerbi-visuals-utils/color": "git+https://github.com/vtkalek/powerbi-visuals-utils-color.git",
"@powerbi-visuals-utils/dataviewobjects": "git+https://github.com/ignatvilesov/powerbi-visuals-utils-dataviewobjects.git",
"d3": "3.5.5",
"globalize": "0.1.0-a2",
"jquery": "3.1.1",
"lodash": "4.16.2",
"moment": "2.15.1",
"powerbi-visuals-tools": "1.2.0",
"powerbi-visuals-tools": "1.3.0",
"powerbi-visuals-utils-chartutils": "^0.2.3",
"powerbi-visuals-utils-colorutils": "^0.2.1",
"powerbi-visuals-utils-dataviewutils": "^0.3.0",
"powerbi-visuals-utils-formattingutils": "^0.2.2",
"powerbi-visuals-utils-interactivityutils": "^0.2.1",
"powerbi-visuals-utils-svgutils": "^0.2.1",
"powerbi-visuals-utils-tooltiputils": "^0.3.0",
"tslint": "3.15.1",
"typings": "1.4.0"
}

Просмотреть файл

@ -4,12 +4,12 @@
"displayName": "Radar Chart",
"guid": "RadarChart1446119667547",
"visualClassName": "RadarChart",
"version": "0.5.5",
"version": "0.5.6",
"description": "A simple radar chart supporting multiple measures plotted over a categorical axis. Also known as a web chart, spider chart, or star chart. Use to display performance metrics for quality improvement.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/PowerBI-visuals-RadarChart"
},
"apiVersion": "1.2.0",
"apiVersion": "1.3.0",
"author": {
"name": "Microsoft",
"email": "pbicvsupport@microsoft.com"
@ -18,37 +18,19 @@
"icon": "assets/icon.png"
},
"externalJS": [
"node_modules/@powerbi-visuals-utils/external-loader/lib/index.js",
"node_modules/jquery/dist/jquery.min.js",
"node_modules/d3/d3.min.js",
"node_modules/lodash/lodash.min.js",
"node_modules/d3/d3.js",
"node_modules/moment/min/moment.min.js",
"node_modules/globalize/lib/globalize.js",
"node_modules/globalize/lib/cultures/globalize.culture.en-US.js",
"node_modules/@powerbi-visuals-utils/stringextensions/lib/index.js",
"node_modules/@powerbi-visuals-utils/cssconstants/lib/index.js",
"node_modules/@powerbi-visuals-utils/pixelconverter/lib/index.js",
"node_modules/@powerbi-visuals-utils/arrayextensions/lib/index.js",
"node_modules/@powerbi-visuals-utils/shapes/lib/index.js",
"node_modules/@powerbi-visuals-utils/interactivityservice/lib/index.js",
"node_modules/@powerbi-visuals-utils/colorhelper/lib/index.js",
"node_modules/@powerbi-visuals-utils/rect/lib/index.js",
"node_modules/@powerbi-visuals-utils/pointerutils/lib/index.js",
"node_modules/@powerbi-visuals-utils/controls-touchutils/lib/index.js",
"node_modules/@powerbi-visuals-utils/formatting/lib/index.js",
"node_modules/@powerbi-visuals-utils/formattingservice/lib/index.js",
"node_modules/@powerbi-visuals-utils/valueformatter/lib/index.js",
"node_modules/@powerbi-visuals-utils/svgutil/lib/index.js",
"node_modules/@powerbi-visuals-utils/tooltipservice/lib/index.js",
"node_modules/@powerbi-visuals-utils/tooltipmanager/lib/index.js",
"node_modules/@powerbi-visuals-utils/tooltipbuilder/lib/index.js",
"node_modules/@powerbi-visuals-utils/fontutils/lib/index.js",
"node_modules/@powerbi-visuals-utils/interactivityutils/lib/index.js",
"node_modules/@powerbi-visuals-utils/localstorageservice/lib/index.js",
"node_modules/@powerbi-visuals-utils/textmeasurementservice/lib/index.js",
"node_modules/@powerbi-visuals-utils/legend/lib/index.js",
"node_modules/@powerbi-visuals-utils/datalabelutils/lib/index.js",
"node_modules/@powerbi-visuals-utils/datalabelmanager/lib/index.js"
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.js",
"node_modules/powerbi-visuals-utils-typeutils/lib/index.js",
"node_modules/powerbi-visuals-utils-svgutils/lib/index.js",
"node_modules/powerbi-visuals-utils-formattingutils/lib/index.js",
"node_modules/powerbi-visuals-utils-colorutils/lib/index.js",
"node_modules/powerbi-visuals-utils-interactivityutils/lib/index.js",
"node_modules/powerbi-visuals-utils-tooltiputils/lib/index.js",
"node_modules/powerbi-visuals-utils-chartutils/lib/index.js"
],
"style": "style/radarChart.less",
"capabilities": "capabilities.json"

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Power BI Visual CLI
* Power BI Visualizations
*
* Copyright (c) Microsoft Corporation
* All rights reserved.
@ -25,21 +25,15 @@
*/
module powerbi.extensibility.visual {
// external libraries
// d3
import Selection = d3.Selection;
import UpdateSelection = d3.selection.Update;
import Arc = d3.svg.arc.Arc;
import SvgArc = d3.svg.Arc;
import Linear = d3.scale.Linear;
// jsCommon
import ClassAndSelector = jsCommon.CssConstants.ClassAndSelector;
import CreateClassAndSelector = jsCommon.CssConstants.createClassAndSelector;
import PixelConverter = jsCommon.PixelConverter;
// powerbi
import DataViewObject = powerbi.DataViewObject;
import DataLabelManager = powerbi.DataLabelManager;
import IDataViewObject = powerbi.DataViewObject;
import PrimitiveValue = powerbi.PrimitiveValue;
import IViewport = powerbi.IViewport;
import DataViewObjectPropertyIdentifier = powerbi.DataViewObjectPropertyIdentifier;
@ -48,9 +42,7 @@ module powerbi.extensibility.visual {
import DataViewValueColumns = powerbi.DataViewValueColumns;
import DataViewValueColumnGroup = powerbi.DataViewValueColumnGroup;
import DataViewMetadataColumn = powerbi.DataViewMetadataColumn;
import TextProperties = powerbi.TextProperties;
import TextMeasurementService = powerbi.TextMeasurementService;
import DataViewObjects = powerbi.DataViewObjects;
import IDataViewObjects = powerbi.DataViewObjects;
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
import VisualObjectInstanceEnumeration = powerbi.VisualObjectInstanceEnumeration;
import VisualObjectInstance = powerbi.VisualObjectInstance;
@ -64,52 +56,91 @@ module powerbi.extensibility.visual {
import IVisualHost = powerbi.extensibility.visual.IVisualHost;
// powerbi.visuals
import IMargin = powerbi.visuals.IMargin;
import IInteractivityService = powerbi.visuals.IInteractivityService;
import IInteractiveBehavior = powerbi.visuals.IInteractiveBehavior;
import createInteractivityService = powerbi.visuals.createInteractivityService;
import ColorHelper = powerbi.visuals.ColorHelper;
import IVisualSelectionId = powerbi.visuals.ISelectionId;
import valueFormatter = powerbi.visuals.valueFormatter;
import IValueFormatter = powerbi.visuals.IValueFormatter;
import TooltipBuilder = powerbi.visuals.TooltipBuilder;
import ITooltipService = powerbi.visuals.ITooltipService;
import VisualTooltipDataItem = powerbi.visuals.VisualTooltipDataItem;
import TooltipEventArgs = powerbi.visuals.TooltipEventArgs;
import createTooltipService = powerbi.visuals.createTooltipService;
import SVGUtil = powerbi.visuals.SVGUtil;
import LegendData = powerbi.visuals.LegendData;
import LegendIcon = powerbi.visuals.LegendIcon;
import ILegend = powerbi.visuals.ILegend;
import createLegend = powerbi.visuals.createLegend;
import LegendPosition = powerbi.visuals.LegendPosition;
import legendProps = powerbi.visuals.legendProps;
import Legend = powerbi.visuals.Legend;
import legendPosition = powerbi.visuals.legendPosition;
import LabelEnabledDataPoint = powerbi.visuals.LabelEnabledDataPoint;
import ILabelLayout = powerbi.visuals.ILabelLayout;
// powerbi.extensibility.utils.svg
import IMargin = powerbi.extensibility.utils.svg.IMargin;
import translate = powerbi.extensibility.utils.svg.translate;
import ClassAndSelector = powerbi.extensibility.utils.svg.CssConstants.ClassAndSelector;
import CreateClassAndSelector = powerbi.extensibility.utils.svg.CssConstants.createClassAndSelector;
// powerbi.extensibility.utils.formatting
import TextProperties = powerbi.extensibility.utils.formatting.TextProperties;
import valueFormatter = powerbi.extensibility.utils.formatting.valueFormatter;
import IValueFormatter = powerbi.extensibility.utils.formatting.IValueFormatter;
import textMeasurementService = powerbi.extensibility.utils.formatting.textMeasurementService;
// powerbi.extensibility.utils.interactivity
import IInteractivityService = powerbi.extensibility.utils.interactivity.IInteractivityService;
import IInteractiveBehavior = powerbi.extensibility.utils.interactivity.IInteractiveBehavior;
import createInteractivityService = powerbi.extensibility.utils.interactivity.createInteractivityService;
// powerbi.extensibility.utils.type
import PixelConverter = powerbi.extensibility.utils.type.PixelConverter;
// powerbi.extensibility.utils.color
import ColorHelper = powerbi.extensibility.utils.color.ColorHelper;
// powerbi.extensibility.utils.tooltip
import TooltipEventArgs = powerbi.extensibility.utils.tooltip.TooltipEventArgs;
import ITooltipServiceWrapper = powerbi.extensibility.utils.tooltip.ITooltipServiceWrapper;
import createTooltipServiceWrapper = powerbi.extensibility.utils.tooltip.createTooltipServiceWrapper;
// powerbi.extensibility.utils.dataview
import DataViewObject = powerbi.extensibility.utils.dataview.DataViewObject;
import DataViewObjects = powerbi.extensibility.utils.dataview.DataViewObjects;
// powerbi.extensibility.utils.chart
import LegendModule = powerbi.extensibility.utils.chart.legend;
import ILegend = powerbi.extensibility.utils.chart.legend.ILegend;
import LegendData = powerbi.extensibility.utils.chart.legend.LegendData;
import LegendDataModule = powerbi.extensibility.utils.chart.legend.data;
import LegendIcon = powerbi.extensibility.utils.chart.legend.LegendIcon;
import legendProps = powerbi.extensibility.utils.chart.legend.legendProps;
import legendPosition = powerbi.extensibility.utils.chart.legend.position;
import createLegend = powerbi.extensibility.utils.chart.legend.createLegend;
import LegendPosition = powerbi.extensibility.utils.chart.legend.LegendPosition;
import ILabelLayout = powerbi.extensibility.utils.chart.dataLabel.ILabelLayout;
import DataLabelManager = powerbi.extensibility.utils.chart.dataLabel.DataLabelManager;
import LabelEnabledDataPoint = powerbi.extensibility.utils.chart.dataLabel.LabelEnabledDataPoint;
export class RadarChart implements IVisual {
private static formatStringProp: DataViewObjectPropertyIdentifier = {
objectName: "general",
propertyName: "formatString",
};
private static Properties: any = {
private static Properties = {
legend: {
show: <DataViewObjectPropertyIdentifier>{ objectName: "legend", propertyName: "show" }
show: {
objectName: "legend",
propertyName: "show"
} as DataViewObjectPropertyIdentifier
},
line: {
show: <DataViewObjectPropertyIdentifier>{ objectName: "line", propertyName: "show" },
lineWidth: <DataViewObjectPropertyIdentifier>{ objectName: "line", propertyName: "lineWidth" }
show: {
objectName: "line",
propertyName: "show"
} as DataViewObjectPropertyIdentifier,
lineWidth: {
objectName: "line",
propertyName: "lineWidth"
} as DataViewObjectPropertyIdentifier
},
dataPoint: {
fill: <DataViewObjectPropertyIdentifier>{ objectName: "dataPoint", propertyName: "fill" }
fill: {
objectName: "dataPoint",
propertyName: "fill"
} as DataViewObjectPropertyIdentifier
},
labels: {
show: <DataViewObjectPropertyIdentifier>{ objectName: "labels", propertyName: "show" },
color: <DataViewObjectPropertyIdentifier>{ objectName: "labels", propertyName: "color" },
fontSize: <DataViewObjectPropertyIdentifier>{ objectName: "labels", propertyName: "fontSize" }
show: {
objectName: "labels",
propertyName: "show"
} as DataViewObjectPropertyIdentifier,
color: {
objectName: "labels",
propertyName: "color"
} as DataViewObjectPropertyIdentifier,
fontSize: {
objectName: "labels",
propertyName: "fontSize"
} as DataViewObjectPropertyIdentifier
}
};
@ -210,11 +241,11 @@ module powerbi.extensibility.visual {
private behavior: IInteractiveBehavior;
private visualHost: IVisualHost;
private tooltipService: ITooltipService;
private tooltipServiceWrapper: ITooltipServiceWrapper;
private margin: IMargin;
private legend: ILegend;
private legendObjectProperties: DataViewObject;
private legendObjectProperties: IDataViewObject;
private radarChartData: RadarChartData;
private angle: number;
@ -365,13 +396,10 @@ module powerbi.extensibility.visual {
.withSeries(dataView.categorical.values, columnGroup)
.createSelectionId();
let tooltipInfo: VisualTooltipDataItem[] = TooltipBuilder.createTooltipInfo(
RadarChart.formatStringProp,
let tooltipInfo: VisualTooltipDataItem[] = tooltipBuilder.createTooltipInfo(
catDv,
catDv.categories[0].values[k],
values[i].values[k],
null,
null,
i);
let labelFormatString: string = valueFormatter.getFormatStringByColumn(catDv.values[i].source),
@ -432,7 +460,9 @@ module powerbi.extensibility.visual {
this.interactivityService = createInteractivityService(options.host);
this.behavior = new RadarChartWebBehavior();
this.tooltipService = createTooltipService(options.host);
this.tooltipServiceWrapper = createTooltipServiceWrapper(
options.host.tooltipService,
options.element);
this.legend = createLegend(
$(element),
@ -517,7 +547,7 @@ module powerbi.extensibility.visual {
this.mainGroupElement.attr(
"transform",
SVGUtil.translate(this.viewport.width / 2, this.viewport.height / 2));
translate(this.viewport.width / 2, this.viewport.height / 2));
let labelsFontSize: number = this.radarChartData.settings.labels.fontSize;
@ -652,7 +682,7 @@ module powerbi.extensibility.visual {
text: this.radarChartData.labels.formatter.format(label.text)
};
return TextMeasurementService.getTailoredTextOrDefault(properties, label.maxWidth);
return textMeasurementService.getTailoredTextOrDefault(properties, label.maxWidth);
},
labelLayout: {
x: (label: RadarChartLabel) => label.x,
@ -725,7 +755,7 @@ module powerbi.extensibility.visual {
labelsSelection
.attr({
dy: `${RadarChart.LabelYOffset}em`,
transform: SVGUtil.translate(
transform: translate(
RadarChart.LabelXOffset,
-RadarChart.LabelYOffset * labelSettings.fontSize),
x: (label: RadarChartLabel) => label.x,
@ -738,7 +768,7 @@ module powerbi.extensibility.visual {
text: this.radarChartData.labels.formatter.format(label.text)
};
return TextMeasurementService.getTailoredTextOrDefault(properties, label.maxWidth);
return textMeasurementService.getTailoredTextOrDefault(properties, label.maxWidth);
})
.style("font-size", () => PixelConverter.fromPoint(labelSettings.fontSize))
.style("text-anchor", (label: RadarChartLabel) => label.textAnchor)
@ -867,7 +897,7 @@ module powerbi.extensibility.visual {
.exit()
.remove();
this.tooltipService.addTooltip(
this.tooltipServiceWrapper.addTooltip(
dotsSelection,
(eventArgs: TooltipEventArgs<RadarChartDatapoint>) => {
return eventArgs.data.tooltipInfo;
@ -936,7 +966,7 @@ module powerbi.extensibility.visual {
legendData: LegendData = radarChartData.legendData;
if (this.legendObjectProperties) {
LegendData.update(legendData, this.legendObjectProperties);
LegendDataModule.update(legendData, this.legendObjectProperties);
let position: string = this.legendObjectProperties[legendProps.position] as string;
@ -948,7 +978,7 @@ module powerbi.extensibility.visual {
}
this.legend.drawLegend(legendData, { height, width });
Legend.positionChartArea(this.svg, this.legend);
LegendModule.positionChartArea(this.svg, this.legend);
}
private getDataPoints(seriesList: RadarChartSeries[]): RadarChartDatapoint[][] {
@ -994,7 +1024,7 @@ module powerbi.extensibility.visual {
}
private static parseSettings(dataView: DataView, colorPalette: IColorPalette): RadarChartSettings {
let objects: DataViewObjects = null,
let objects: IDataViewObjects = null,
defaultSettings: RadarChartSettings = RadarChart.DefaultSettings;
if (dataView
@ -1024,7 +1054,7 @@ module powerbi.extensibility.visual {
};
}
private static parseLabelSettings(objects: DataViewObjects, colorPalette: IColorPalette): RadarChartLabelSettings {
private static parseLabelSettings(objects: IDataViewObjects, colorPalette: IColorPalette): RadarChartLabelSettings {
let settings: RadarChartLabelSettings = <RadarChartLabelSettings>{},
defaultSettings: RadarChartLabelSettings = RadarChart.DefaultLabelSettings;
@ -1191,20 +1221,20 @@ module powerbi.extensibility.visual {
legendPosition = LegendPosition[this.legendObjectProperties[legendProps.position] as string];
switch (legendPosition) {
case powerbi.visuals.LegendPosition.Top:
case powerbi.visuals.LegendPosition.TopCenter:
case powerbi.visuals.LegendPosition.Bottom:
case powerbi.visuals.LegendPosition.BottomCenter: {
case LegendPosition.Top:
case LegendPosition.TopCenter:
case LegendPosition.Bottom:
case LegendPosition.BottomCenter: {
this.viewport.height = Math.max(
this.viewport.height - legendMargins.height,
RadarChart.MinViewport.height);
break;
}
case powerbi.visuals.LegendPosition.Left:
case powerbi.visuals.LegendPosition.LeftCenter:
case powerbi.visuals.LegendPosition.Right:
case powerbi.visuals.LegendPosition.RightCenter: {
case LegendPosition.Left:
case LegendPosition.LeftCenter:
case LegendPosition.Right:
case LegendPosition.RightCenter: {
this.viewport.width = Math.max(
this.viewport.width - legendMargins.width,
RadarChart.MinViewport.width);

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Power BI Visual CLI
* Power BI Visualizations
*
* Copyright (c) Microsoft Corporation
* All rights reserved.
@ -25,15 +25,18 @@
*/
module powerbi.extensibility.visual {
// external libraries
// d3
import Arc = d3.svg.arc.Arc;
// powerbi.visuals
import SelectableDataPoint = powerbi.visuals.SelectableDataPoint;
import VisualTooltipDataItem = powerbi.visuals.VisualTooltipDataItem;
import LegendData = powerbi.visuals.LegendData;
import IValueFormatter = powerbi.visuals.IValueFormatter;
import IInteractivityService = powerbi.visuals.IInteractivityService;
// powerbi.extensibility.utils.chart.legend
import LegendData = powerbi.extensibility.utils.chart.legend.LegendData;
// powerbi.extensibility.utils.formatting
import IValueFormatter = powerbi.extensibility.utils.formatting.IValueFormatter;
// powerbi.extensibility.utils.interactivity
import SelectableDataPoint = powerbi.extensibility.utils.interactivity.SelectableDataPoint;
import IInteractivityService = powerbi.extensibility.utils.interactivity.IInteractivityService;
export interface RadarChartDatapoint extends SelectableDataPoint {
x: number;

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Power BI Visual CLI
* Power BI Visualizations
*
* Copyright (c) Microsoft Corporation
* All rights reserved.

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Power BI Visual CLI
* Power BI Visualizations
*
* Copyright (c) Microsoft Corporation
* All rights reserved.
@ -25,14 +25,14 @@
*/
module powerbi.extensibility.visual {
// external libraries
// d3
import Selection = d3.Selection;
// powerbi.visuals
import SelectableDataPoint = powerbi.visuals.SelectableDataPoint;
import IInteractivityService = powerbi.visuals.IInteractivityService;
import IInteractiveBehavior = powerbi.visuals.IInteractiveBehavior;
import ISelectionHandler = powerbi.visuals.ISelectionHandler;
// powerbi.extensibility.utils.interactivity
import SelectableDataPoint = powerbi.extensibility.utils.interactivity.SelectableDataPoint;
import IInteractivityService = powerbi.extensibility.utils.interactivity.IInteractivityService;
import IInteractiveBehavior = powerbi.extensibility.utils.interactivity.IInteractiveBehavior;
import ISelectionHandler = powerbi.extensibility.utils.interactivity.ISelectionHandler;
export interface RadarChartBehaviorOptions {
selection: Selection<SelectableDataPoint>;

214
src/tooltipBuilder.ts Normal file
Просмотреть файл

@ -0,0 +1,214 @@
/*
* 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.
*/
module powerbi.extensibility.visual.tooltipBuilder {
// powerbi.extensibility.utils.formatting
import valueFormatter = powerbi.extensibility.utils.formatting.valueFormatter;
const DefaultSeriesIndex: number = 0;
const HighlightedValueDisplayName: string = "Highlighted";
const DefaultDisplayName: string = "";
const DisplayNameSeparator: string = "/";
export interface TooltipCategoryDataItem {
value?: any;
metadata: DataViewMetadataColumn[];
}
export interface TooltipSeriesDataItem {
value?: any;
highlightedValue?: any;
metadata: DataViewValueColumn;
}
export function createTooltipInfo(
dataViewCat: DataViewCategorical,
categoryValue: any,
value?: any,
seriesIndex?: number): VisualTooltipDataItem[] {
let categorySource: TooltipCategoryDataItem,
seriesSource: TooltipSeriesDataItem[] = [],
valuesSource: DataViewMetadataColumn = undefined;
seriesIndex = seriesIndex | DefaultSeriesIndex;
let categoriesData: DataViewCategoricalColumn[] = dataViewCat && dataViewCat.categories;
if (categoriesData && categoriesData.length > 0) {
if (categoriesData.length > 1) {
let compositeCategoriesData: DataViewMetadataColumn[] = [];
for (let i: number = 0, ilen: number = categoriesData.length; i < ilen; i++) {
compositeCategoriesData.push(categoriesData[i].source);
}
categorySource = {
value: categoryValue,
metadata: compositeCategoriesData
};
}
else {
categorySource = {
value: categoryValue,
metadata: [categoriesData[0].source]
};
}
}
if (dataViewCat && dataViewCat.values) {
if (!categorySource || !(categorySource.metadata[0] === dataViewCat.values.source)) {
valuesSource = dataViewCat.values.source;
}
if (dataViewCat.values.length > 0) {
const valueColumn: DataViewValueColumn = dataViewCat.values[seriesIndex],
isAutoGeneratedColumn: boolean = !!(valueColumn
&& valueColumn.source
&& (valueColumn.source as any).isAutoGeneratedColumn);
if (!isAutoGeneratedColumn) {
seriesSource.push({
value,
highlightedValue: undefined,
metadata: valueColumn
});
}
}
return createTooltipData(
categorySource,
valuesSource,
seriesSource);
}
}
function createTooltipData(
categoryValue: TooltipCategoryDataItem,
valuesSource: DataViewMetadataColumn,
seriesValues: TooltipSeriesDataItem[]): VisualTooltipDataItem[] {
const items: VisualTooltipDataItem[] = [];
if (categoryValue) {
if (categoryValue.metadata.length > 1) {
let displayName: string = DefaultDisplayName;
for (let i: number = 0, ilen: number = categoryValue.metadata.length; i < ilen; i++) {
if (i !== 0) {
displayName += DisplayNameSeparator;
}
displayName += categoryValue.metadata[i].displayName;
}
let categoryFormattedValue: string = getFormattedValue(
categoryValue.metadata[0],
categoryValue.value);
items.push({
displayName,
value: categoryFormattedValue
});
}
else {
let categoryFormattedValue: string = getFormattedValue(
categoryValue.metadata[0],
categoryValue.value);
items.push({
displayName: categoryValue.metadata[0].displayName,
value: categoryFormattedValue
});
}
}
if (valuesSource) {
let dynamicValue: string;
if (seriesValues.length > 0) {
let dynamicValueMetadata: DataViewMetadataColumn = seriesValues[0].metadata.source;
dynamicValue = getFormattedValue(
valuesSource,
dynamicValueMetadata.groupName);
}
items.push({
displayName: valuesSource.displayName,
value: dynamicValue
});
}
for (let i: number = 0; i < seriesValues.length; i++) {
let seriesData: TooltipSeriesDataItem = seriesValues[i];
if (seriesData && seriesData.metadata) {
let seriesMetadataColumn: DataViewMetadataColumn = seriesData.metadata.source,
value: any = seriesData.value,
highlightedValue: any = seriesData.highlightedValue;
if (value || value === 0) {
let formattedValue: string = getFormattedValue(seriesMetadataColumn, value);
items.push({
displayName: seriesMetadataColumn.displayName,
value: formattedValue
});
}
if (highlightedValue || highlightedValue === 0) {
let formattedHighlightedValue: string = getFormattedValue(
seriesMetadataColumn,
highlightedValue);
items.push({
displayName: HighlightedValueDisplayName,
value: formattedHighlightedValue
});
}
}
}
return items;
}
export function getFormattedValue(column: DataViewMetadataColumn, value: any): string {
const formatString: string = getFormatStringFromColumn(column);
return valueFormatter.format(value, formatString);
}
function getFormatStringFromColumn(column: DataViewMetadataColumn): string {
if (column) {
const formatString: string = valueFormatter.getFormatStringByColumn(column, true);
return formatString || column.format;
}
return null;
}
}

Просмотреть файл

@ -28,9 +28,8 @@
* Imports external styles.
* We compile it as a less file in order to wrap the external CSS rules.
*/
@import (less) "node_modules/@powerbi-visuals-utils/tooltipmanager/lib/index.css";
@import (less) "node_modules/@powerbi-visuals-utils/interactivityservice/lib/index.css";
@import (less) "node_modules/@powerbi-visuals-utils/legend/lib/index.css";
@import (less) "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.css";
@import (less) "node_modules/powerbi-visuals-utils-chartutils/lib/index.css";
.radarChart {
@defaultColor: grey;

Просмотреть файл

@ -10,36 +10,19 @@
},
"files": [
"typings/index.d.ts",
".api/v1.2.0/PowerBI-visuals.d.ts",
"node_modules/@powerbi-visuals-utils/imargin/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/cssconstants/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/pixelconverter/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/displayunitsystemtype/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/displayunitsystem/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/stringextensions/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/formattingservice/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/valuetype/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/valueformatter/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/standaloneutility/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/shapes/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/interactivityservice/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/colorhelper/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/point/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/rect/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/controls-touchutils/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/svgutil/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/tooltipservice/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/tooltipmanager/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/tooltipbuilder/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/dataviewobjects/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/color/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/legend/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/datalabelutils/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/textmeasurementservice/lib/index.d.ts",
"node_modules/@powerbi-visuals-utils/datalabelmanager/lib/index.d.ts",
".api/v1.3.0/PowerBI-visuals.d.ts",
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-colorutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-formattingutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-tooltiputils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts",
"src/radarChartDataInterfaces.ts",
"src/tooltipBuilder.ts",
"src/radarChartUtils.ts",
"src/radarChartWebBehavior.ts",
"src/radarChart.ts"
]
}
}

Просмотреть файл

@ -2,6 +2,6 @@
"globalDependencies": {
"d3": "registry:dt/d3#0.0.0+20160907005744",
"jquery": "registry:dt/jquery#1.10.0+20160929162922",
"lodash": "registry:dt/lodash#4.14.0+20161004174455"
"lodash": "registry:dt/lodash#4.14.0+20161110215204"
}
}