
# Install Pivot

※ Note: RealPivot does not support web accessibility.

<GridView demo='pivotguides/01-pivotTutorial/01' height={700}/>

#### STEP 1. Create and connect dataProvider and pivot objects

```js
dataProvider = new RealGrid.LocalDataProvider();
//Create pivot object
pivot = new RealPivot("realpivot");
pivot.setDataProvider(dataProvider);
```


#### STEP 2. Data Provider field creation and pivot field Mapping

```js
var fields = [{
     fieldName:"Domestic/Imported"
},{
     fieldName:"Country"
},{
     fieldName:"Brand number"
},{
     fieldName:"Brand Name"
},{
     fieldName:"Model number"
},{
     fieldName:"Model name"
},{
     fieldName:"Color number"
},{
     fieldName:"Color"
},{
     fieldName:"Sale Date",
     dataType:"datetime",
     datetimeFormat:"yyyy-MM-dd"
},{
     fieldName:"Sales Quantity",
     dataType:"number"
},{
     fieldName:"Vehicle price",
     dataType:"number"
},{
     fieldName:"Car type"
},{
     fieldName:"Fuel"
}];

dataProvider.setFields(fields);

pivot.setFieldMapping([{
     name: "Country",
     sourceField: "Country"
},{
     name: "Brand name",
     sourceField: "Brand Name"
},{
     name: "Sales Quarter",
     sourceField: "Sale Date",
     dateType:"quarter",
     fieldHeader:"branch",
     displayFormat: "${value}quarter",
     summaryFormat: "${value}Quarter Sum"
},{
     name: "Year of sale",
     sourceField: "Sale Date",
     dateType: "year",
     fieldHeader: "Year",
     displayFormat: "${value}year",
     summaryFormat: "Sum of ${value} years"
},{
     name: "Sale Month",
     sourceField: "Sale Date",
     dateType: "month",
     fieldHeader: "month",
     displayFormat: "${value}month",
     summaryFormat: "${value}monthly sum"
},{
     name: "Sales Quantity",
     sourceField: "Sales Quantity",
     numberFormat:"#,##0"
},{
     name: "Vehicle price",
     sourceField: "Vehicle price",
     numberFormat:"#,##0"
},{
     name:"Car type",
     sourceField:"Car type"
}]);

pivot.setPivotFields({
     columns: ["Sales Quarter","Sales Month"],
     rows: ["Brand Name","Car Model"],
     values: [{
         name: "Vehicle price",
         expression: "sum"
     }, {
         name: "Sales Quantity",
         expression: "sum"
     }]
});
```

#### STEP 3. Load data

```js
$.ajax({
     url: "/data/pivotDataSet.json",
     success: function (data) {
         dataProvider.fillJsonData(data,{count:5000});
     },
     complete: function(data){
     }
});
```

#### STEP 4. Draw pivot

```js
pivot.drawView();
```