Skip to content

Commit

Permalink
Updated some of the R Powered Custom Visuals docs
Browse files Browse the repository at this point in the history
Based on initial review from the team.
Need more text proofing to be done
  • Loading branch information
raananzvi committed Oct 6, 2016
1 parent 72475ac commit f5ddb96
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions RVisualTutorial/CorrplotScript.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Editing the R Script
When creating a R Custom Visual, the template "rvisual" creates a file in the root folder of the visual called "script.r".
When creating a R Powered Custom Visual, the template "rvisual" creates a file in the root folder of the visual called "script.r".
This file will hold the R script you want to execute to generate the image the user will see.

In this stage, we will change the default R script to start using the Corrplot package.
We will use the following introduction to corrplot [introduction](https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html)
We will follow the corrplot [introduction](https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html) from cran.r-project.org

## Editing the R Script
Open the "script.r" file and paste the following code:
Expand Down
8 changes: 4 additions & 4 deletions RVisualTutorial/CreateNewVisual.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Building a new R Custom Visual
In order to start a new R Custom Visual we will run the following command:
# Building a new R Powered Custom Visual
In order to create a new R Powered Custom Visual we will run the following command:

```
pbiviz new sampleCorrPlotRVisual -t rvisual --api-version 1.2.0
pbiviz new sampleCorrPlotRVisual -t rvisual
```

This command will create a new folder stracture based on the template "rvisual"
Expand All @@ -13,7 +13,7 @@ This template includes a very basic ready to run R Visual which will actually ru
plot(Values)
```

This script will generate a very basic plot of whatever the user will drag to the Values data role
This R script calls a generic function for plotting of R object. The data frame "Values" will contian columns in "Values" data role.

![Basic Plot Script Result](images/BasicPlot.png)

Expand Down
2 changes: 1 addition & 1 deletion RVisualTutorial/InputValidationInR.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Input Validation in R Script
In order to write a real robust R Custom Visual, you should validate all the input you get before running some R function that expects specific values to be given.
In order to write a truly robust R Powered Custom Visual, you should validate all the input you get before running some R function that expects specific values to be given.

For example, the corrplot function needs to run on at least two columns and at least two rows.
If the function gets one row, the function will fail.
Expand Down
15 changes: 7 additions & 8 deletions RVisualTutorial/PropertiesPane.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Controlling the R Script from the Property Pane
In order to control the behavior of the R Script based on user input, one can add properties to the property pane.
This way users will be able to play with the visual to get to the exact look and feel they want, or even control advanced
algorithm properties for more complex visuals that will run forecasting or other algorithms
In order to enhance the behavior of the R Script based on user input, one can add properties to the property pane.
This way users will be able to control the visual to get to the exact look and feel they want

## Adding enum property to control the look and feel of the visual
Corrplot can be easily be configured using the `method` argument for the `corrplot` function.
## Adding enumeration property
Corrplot can be easily configured using the `method` argument for the `corrplot` function.
Our default script just used `circle`, but we can expose this property to the user and have her choose between the options.

### Defining the enumeration property for controlling the `method` argument
Expand Down Expand Up @@ -56,12 +55,12 @@ and we will supply the valid values for this property
}
```
### Exposing the property to the users in the property pane
In order for the above property be exposed in the property pane, we will need to touch the TypeScript code as well.
In order for the above property to be exposed in the property pane, we will need to change the TypeScript code as well.
Open the `src/visual.ts` file and start editing it

In the `visual.ts` file we have added several code snippets as comments, so you can start from there.

First, let define a new interface to hold the property value. We will hold the enumeration value in this property
First, let's define a new interface to hold the property value. We will hold the enumeration value in this property

```
interface VisualSettings {
Expand Down Expand Up @@ -109,7 +108,7 @@ public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions):
```

The last thing we need to take care of is the actual R script to start using this property
We need to handle the case where we don't get any value for this property. This happens when the user didn't play with the property pane.
We need to handle the case where we don't get any value for this property. This happens when the user makes no changes in the property pane.
The naming convention of the R runtime variables for the properties is as follows:

`<objectname>_<propertyname>`
Expand Down
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ In this tutorial, you will be building a simple bar chart. The source code is lo
6. [Adding Databound Objects to Property Pane](Tutorial/DataBoundObjects.md)
7. [Finally Package for Distribution ... Done!](tools/usage.md#packaging-your-visual-for-distribution)

### Building R Custom Visual (corrplot)
1. [Creating a new R Custom Visual](RVisualTutorial/CreateNewVisual.md)
### Building R Powered Custom Visual (corrplot)
1. [Creating a new R Powered Custom Visual](RVisualTutorial/CreateNewVisual.md)
2. [Starting a simple R Script](RVisualTutorial/CorrplotScript.md)
3. [Adding a static property to the property pane](RVisualTutorial/PropertiesPane.md)
4. [Validate input data in R Script](RVisualTutorial/InputValidationInR.md)
Expand Down

0 comments on commit f5ddb96

Please sign in to comment.