Giter Site home page Giter Site logo

microsoft / powerbi-report-authoring Goto Github PK

View Code? Open in Web Editor NEW
37.0 13.0 19.0 108 KB

A library for authoring Power BI reports while embedded into your apps. Provides service which makes it easy to change report and visual elements in session. It gives APIs such as creating visual, changing visual properties, etc ...

License: MIT License

JavaScript 12.41% TypeScript 87.59%

powerbi-report-authoring's Introduction

powerbi-report-authoring

This library is an extension of powerbi-client library. While powerbi-client library helps for embedding Power BI reports into your apps, powerbi-report-authoring helps for editing Power BI reports programatically.

NPM Version Nuget Version NPM Total Downloads NPM Monthly Downloads GitHub tag Gitter

Wiki

See powerbi-client wiki for more details about embedding Power BI reports.

See powerbi-report-authoring wiki for more details about authoring Power BI reports in embed session.

Install from NPM:

npm install --save powerbi-report-authoring

Include the library via import or manually

Ideally you would use module loader or compilation step to import using ES6 modules as:

import 'powerbi-report-authoring';

However, the library is exported as a Universal Module and the powerbi-report-authoring.js script can be included before your apps closing </body> tag and after including powerbi-client as:

<script src="<path>/powerbi-client/dist/powerbi.js"></script>
<script src="<path>/powerbi-report-authoring/dist/powerbi-report-authoring.js"></script>

When included directly the library is extending classes and interfaces from 'powerbi-client' library.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

powerbi-report-authoring's People

Contributors

ali-hamud avatar anant-k-singh avatar ankitk20 avatar may-hartov avatar mayur007b avatar microsoftopensource avatar msftenhanceprovenance avatar msftgits avatar neryaco avatar ohadedry avatar orshemesh16 avatar submarine-launched avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powerbi-report-authoring's Issues

Enhancement request for data binding

Hi

I'm working on a rather dynamic embedding solution, and have 2 requests:

  1. removeDataField shouldn't auto refresh the report - I want to remove multiple elements from the Row collection of a matrix visual, and only when I'm done, I would like to manually call the refresh method.

  2. addDataField needs to take an index position or something similar where you wan't it to be inserted. It is no good, that it is always added to the end of the array.

Keep up the good work.

BR David

AddDataField missing functionality - "Show items with no data"

Hello PowerBI guys!,

PowerBI - Desktop has the ability to add: "Show items with no data" to certain measures.

image
giving a result like this:

image

However, when using powerbi-report-authoring to set the "Category" (Axis) with the same measure(MonthYear) constructed like this:

const newPrimaryDataField: models.IColumnTarget = {
                $schema: 'http://powerbi.com/product/schema#column',
                column: 'MonthYear',
                table: Table_name
            };

//  Apply new data field
visual.addDataField('Category', newPrimaryDataField);

the end result is a chart with only items with data:

image

So the main question here is the following:

Is there a way to replicate the "Show items with no data" functionality from PowerBI-Desktop into the structure of the measure created with PowerBI-report-authoring so that the output is the same as in PowerBI-Desktop?

Thank you.

addPage method

Apologies if I've completely misunderstood this, but how do I access the addPage() method as documented here https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/page-operations#add-a-page

Add a page

To add a new page to the current report, use the addPage method of the Power BI Client Report class:

addPage(displayName?: string): Promise<Page>
  • displayName sets the display name for the new page. If not specified, the display name is set to Page#<NUM>.
  • The function returns a Page instance of the new page.

For example, add a page with the display name Sales to the current report:

let newPage = await report.addPage("Sales");

I thought it was an extension applied to the core client library implemented within this library but it doesn't seem to be?

removeDataField: will remove the same datafield which has diffrent index

I was trying to use visual.addDataField first to add new data fields and then use visual.removeDataField to remove old data fields.

For example, the initial dataFields is [dataField 1, dataField 2]. After addDataField, I got dataFields = [dataField 1(old), dataField 2(old), dataField 1(new), dataField 2(new)]. I want to remove the first two old dataFields in the array. But when I use:

            visual.getDataFields(dataRole).then((dataFields) => {
                  dataFields.forEach((datafield, index) => {
                    if (index < 2) {
                      visual.removeDataField(dataRole, 0);
                    }
                  });
                });

I expect to get dataFields = [dataField 1(new), dataField 2(new)], but I got dataFields = [ ] instead.

addDatafield - field is not added to the correct position of the fields array, adds to the last position

I used addDataField function to add data to a selected position (index) of the fields array, But it always adds to the last position
0: {$schema: "http://powerbi.com/product/schema#column", column: "column1", table: "table1"}
1: {$schema: "http://powerbi.com/product/schema#column", column: "column2", table: "table2"}
2: {$schema: "http://powerbi.com/product/schema#column", column: "column3", table: "table3"}
3: {$schema: "http://powerbi.com/product/schema#column", column: "column4", table: "table4"}
4: {$schema: "http://powerbi.com/product/schema#column", column: "column5", table: "table5"}
5: {$schema: "http://powerbi.com/product/schema#column", column: "column6", table: "table6"}

This is in Table type widget available in a power bi report, Any idea why

How to get/set actionButton visual properties

I am trying to set the text of an actionButton using the following code, but receive an "Unsupported property" exception. How do you set the actionButton's text property?

https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/visual-properties#selecting-the-format-object-and-property

"powerbi-client": "2.18.7",
"powerbi-report-authoring": "1.1.3",
const buttonText = await visual.getProperty({ objectName: 'text', propertyName: 'text' });

{
	"name": "f2577fc59e2d790abb85",
	 singleVisual": {
		"visualType": "actionButton",
		"objects": {
			text": [
				{
					"properties": {
						"show": {
							"expr": {
								"Literal": {
									"Value": "true"
								}
							}
						}
					}
				},
				{
					"properties": {
						"text": {
							"expr": {
								"Literal": {
									"Value": "'Hello World'"
								}
							}
						},
						"fontFamily": {
							"expr": {
								"Literal": {
									"Value": "'''Segoe UI Semibold'', wf_segoe-ui_semibold, helvetica, arial, sans-serif'"
								}
							}
						},
						"fontSize": {
							"expr": {
								"Literal": {
									"Value": "10D"
								}
							}
						}
					},
					"selector": {
						"id": "default"
					}
				}
			],
	},
	"parentGroupName": "20312eb3ab5ac0044dfa"
}

Access textbox value

Hello,
Im not sure this is issue or not, im try to access textbox value using getCapabilities function. for Textbox its doesn't return dataroles for that. Do we have any other way to get textbox value in power bi report.

Thanks,
Chamila.

[Enhancement Request] More options for adding to visuals/datapoints

Currently, when using the library, I am able to do minor items, but, it would be great if there were more options. For example, I would like to highlight a single data point by either changing isn't color or some attribute to bring attention to a specific data point. It would also be good if I could inject some HTML and/or an icon into the title of a visual.

I have built a discussion system for a project using power bi embedded and I would like to directly highlight or identify where comments are placed in the embedded report. There is not an option to do this programmatically from JavaScript.

addDatafield based on dataSelected event handler

For one project where we use the powerbi API we like to mimic a drill down capability where you can click on a bar for a certain month and that the visual will rerender with all the days for that specific month. We approach this feature by using a combination of the dataselected eventhandler method which triggers the setFilter method with that particular month as a filter.
We then remove the datafield for the month and add the datafield for days.

However, the problem with this approach is that when you select a certain month the bar for that month gets highlighted and all the newly added day bars are darkened. You subsequently have to click on the visual to make the bars light up again. The only option we found so far is to clone the visual, but than we can't see a tooltip anymore and lose some features.

Is there a way to stop the highlighting of the bars or that removedatafield will reset the highlighting?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.