Create project

This commit is contained in:
沐见南 2020-04-25 01:23:56 +08:00
commit 0d14c06cfc
15 changed files with 1564 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/node_modules
/dist
/.tmp
/.vscode

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

164
capabilities.json Normal file
View File

@ -0,0 +1,164 @@
{
"dataRoles": [
{
"displayName": "Field",
"name": "field",
"kind": "Grouping",
"requiredTypes": [
{
"text":true
},
{
"integer": true
},
{
"numeric": true
}
],
"preferredTypes": [
{
"integer":true
},
{
"numeric": true
},
{
"text": true
}
]
},
{
"displayName": "Default Select",
"name": "defaultSelect",
"kind": "Measure"
},
{
"displayName": "Default Start",
"name": "defaultStart",
"kind": "Measure"
},
{
"displayName": "Default End",
"name":"defaultEnd",
"kind":"Measure"
}
],
"objects": {
"dataPoint": {
"displayName": "Data colors",
"properties": {
"defaultColor": {
"displayName": "Default color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"showAllDataPoints": {
"displayName": "Show all",
"type": {
"bool": true
}
},
"fill": {
"displayName": "Fill",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"fillRule": {
"displayName": "Color saturation",
"type": {
"fill": {}
}
},
"fontSize": {
"displayName": "Text Size",
"type": {
"formatting": {
"fontSize": true
}
}
}
}
}
},
"dataViewMappings": [
{
"conditions": [
{
"field":{
"max": 1,
"min": 1
},
"defaultSelect":{
"max": 1,
"min": 0
},
"defaultStart":{
"max": 0,
"min": 0
},
"defaultEnd":{
"max": 0,
"min": 0
}
},
{
"field":{
"max": 1,
"min": 1
},
"defaultSelect":{
"max": 0,
"min": 0
},
"defaultStart":{
"max": 1,
"min": 0
},
"defaultEnd":{
"max": 1,
"min": 0
}
}
],
"categorical": {
"categories": {
"for": {
"in": "field"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"select": [
{
"bind": {
"to": "defaultSelect"
}
},
{
"bind": {
"to": "defaultStart"
}
},
{
"bind": {
"to": "defaultEnd"
}
}
]
}
}
}
]
}

1102
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "visual",
"scripts": {
"pbiviz": "pbiviz",
"start": "pbiviz start",
"package": "pbiviz package",
"lint": "tslint -c tslint.json -p tsconfig.json"
},
"dependencies": {
"@babel/runtime": "7.6.0",
"@babel/runtime-corejs2": "7.6.0",
"@types/d3": "5.7.2",
"d3": "5.12.0",
"powerbi-visuals-utils-dataviewutils": "2.2.1",
"powerbi-visuals-api": "~2.6.1",
"core-js": "3.2.1"
},
"devDependencies": {
"ts-loader": "6.1.0",
"tslint": "^5.18.0",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "3.6.3"
}
}

1
pbiviz.json Normal file
View File

@ -0,0 +1 @@
{"visual":{"name":"syinpoSlicer","displayName":"SyinpoSlicer","guid":"syinpoSlicer1E14A7D0BD9E4C9B99612FBE9E84697A","visualClassName":"Visual","version":"1.0.0","description":"","supportUrl":"","gitHubUrl":""},"apiVersion":"2.6.0","author":{"name":"","email":""},"assets":{"icon":"assets/icon.png"},"externalJS":null,"style":"style/visual.less","capabilities":"capabilities.json","dependencies":null,"stringResources":[]}

View File

@ -0,0 +1,14 @@
"Use strict";
import powerbi from "powerbi-visuals-api";
import DataView = powerbi.DataView;
import * as visualInterfaces from "../visual/visualInterfaces";
import * as viewManager from "./viewManager";
export class layoutManager implements layoutManager{
layout:HTMLElement;
constructor(layout:HTMLElement){
this.layout=layout;
}
updateLayout(dataView:DataView):visualInterfaces.viewManager{
return new viewManager.dropDownViewManager();
}
}

View File

@ -0,0 +1,20 @@
"Use strict";
import {IViewManager} from "../visual/dependencies";
export class dropDownViewManager implements IViewManager{
view: HTMLElement;
updateView(categories: Text, defaultSelect: Text) {
console.debug('dropDownViewManager','updateView')
}
}
export class listViewManager implements IViewManager{
view: HTMLElement;
updateView(categories: Text, defaultSelect: Text) {
console.debug('dropDownViewManager','updateView')
}
}
export class calendalViewManager implements IViewManager{
view: HTMLElement;
updateView(categories: Text, defaultSelect: Text) {
console.debug('dropDownViewManager','updateView')
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.
*/
"use strict";
import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
export class VisualSettings extends DataViewObjectsParser {
public dataPoint: dataPointSettings = new dataPointSettings();
}
export class dataPointSettings {
// Default color
public defaultColor: string = "";
// Show all
public showAllDataPoints: boolean = true;
// Fill
public fill: string = "";
// Color saturation
public fillRule: string = "";
// Text Size
public fontSize: number = 12;
}

83
src/visual/visual.ts Normal file
View File

@ -0,0 +1,83 @@
/*
* Power BI Visual CLI
*
* 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.
*/
"use strict";
import "core-js/stable";
import "./../style/visual.less";
import powerbi from "powerbi-visuals-api";
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
import IVisual = powerbi.extensibility.visual.IVisual;
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
import VisualObjectInstance = powerbi.VisualObjectInstance;
import DataView = powerbi.DataView;
import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject;
import IVisualEventService = powerbi.extensibility.IVisualEventService;
import * as visualInterfaces from "./visualInterfaces";
import { VisualSettings } from "../settings/visualSettings";
import * as viewManager from "../managers/viewManager";
import { layoutManager } from "../managers/layoutManager";
import * as d3 from "d3";
export class Visual implements IVisual {
private events: IVisualEventService;
private target: HTMLElement;
private settings: VisualSettings;
private layoutManager: layoutManager;
private viewManager: visualInterfaces.viewManager;
private view:SVGElement;
constructor(options: VisualConstructorOptions) {
console.log('Visual constructor', options);
this.events = options.host.eventService;
if (document) {
this.layoutManager=new layoutManager(options.element);
}
console.debug('end constructor');
}
public update(options: VisualUpdateOptions) {
console.debug('visual update start');
this.events.renderingStarted(options);
this.settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
let viewManager:visualInterfaces.viewManager=this.layoutManager.updateLayout(options.dataViews[0]);
this.events.renderingFinished(options);
}
private static parseSettings(dataView: DataView): VisualSettings {
return <VisualSettings>VisualSettings.parse(dataView);
}
/**
* This function gets called for each of the objects defined in the capabilities files and allows you to select which of the
* objects and properties you want to expose to the users in the property pane.
*
*/
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
}
}

View File

@ -0,0 +1,14 @@
"Use strict";
import powerbi from "powerbi-visuals-api";
import DataView = powerbi.DataView;
import {VisualSettings} from "../settings/visualSettings";
export interface layoutManager{
layout:HTMLElement;
constructor(layout:HTMLElement):void;
updateLayout(dataView:DataView):viewManager;
}
export interface viewManager{
view:HTMLElement;
updateView(categories:any,defaultSelect:any,defaultStart:any,defaultEnd:any);
}
//interface

9
style/visual.less Normal file
View File

@ -0,0 +1,9 @@
p {
font-size: 20px;
font-weight: bold;
em {
background: yellow;
padding: 5px;
}
}

19
tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./.tmp/build/",
"moduleResolution": "node",
"declaration": true,
"lib": [
"es2015",
"dom"
]
},
"files": [
"src/visual/visual.ts"
]
}

9
tslint.json Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "tslint-microsoft-contrib/recommended",
"rulesDirectory": [
"node_modules/tslint-microsoft-contrib"
],
"rules": {
"no-relative-imports": false
}
}

File diff suppressed because one or more lines are too long