Pivot is a complex widget created with Webix Jet, the MV* framework for Webix Library. It is a ready-to-use application that needs minimal configuration and has an API for redefining the logic of inner modules.
You need to study the source code to customize views and models.
Pivot is built as a Jet App and wrapped in a Webix view, so you can initialize Pivot in either way.
The interface of Pivot is split into parts (views). Each view is a class that extends the JetView class and has its own handlers for setting the configuration and logic.
The sources for interface parts (Jet Views) are located in the sources/views folder.
views
config
properties
index.js
chart.js
mode.js
...
Go to the Class Map page to see the list of all Jet views in Pivot and where they are in the interface.
Pivot models contain the logic for working with data items. They are defined as Jet Services.
The sources for models (Jet Services) are located in the sources/models folder.
models
LocalData.js
Backend.js
Service methods are called by the UI and can be called by a programmer as:
$$("pivot").getService("local").getData();
When you customize a view, you can:
Check the Class Map to find which view renders the part you want to modify.
To use ColorSelector as a custom palette in chart mode create a custom class and inherit it from the default pivot.views["config/properties/values"]. Redefine its ItemConfig() so that it returns config with the colorselect control.
class CustomValuesProperty extends pivot.views["config/properties/values"] {
ItemConfig(val, i) {
const config = super.ItemConfig(val, i);
config[1].suggest = {
padding: 0,
type: "colorselect",
body: {
button: true,
},
};
return config;
}
}
After that you need to override the default view with the new one:
webix.ui({
view: "pivot",
structure: {
rows: ["form", "name"],
columns: ["year"],
values: [{ name: "oil", operation: ["min", "sum"] }],
},
override: new Map([
[pivot.views["config/properties/values"], CustomValuesProperty], ]),
});
Related sample: Pivot: Custom Palette for Chart Mode
See more examples of customization in the How-tos article.
We do not recommend removing any component from the interface as the inner logic might still try accessing it. Instead, hide the components.
class CustomBar extends pivot.views.toolbar {
init(view) {
// default logic
super.init(view);
// hide the "Configure Pivot" button from toolbar
view.queryView("template").hide();
}
}
Within a Jet view, you can access component instances in two ways.
Use the $$(id) method of JetView for an inner component that has the localId setting:
init() {
// default logic
super.init();
// get instance of the component with "config" localId
const config = this.$$("config");
}
Use queryView if localId is not defined:
init(view) {
// default logic
super.init();
// get instance of the first button
const button = view.queryView("icon");
}
You can find out whether the app is currently compact from any view or service method:
const compact = this.getParam("compact", true);
You can get state properties from any view or service method:
const state = this.app.getState();
// or
const state = this.getParam("state");
When you customize a service, you can:
First, create your own service class and inherit it from one of the default services:
class MyBackend extends pivot.services.Backend {
data() {
// client-side data
return webix.promise.resolve(data);
}
}
Then, replace the default service via the override map:
webix.ui({
view: "pivot",
url: "https://docs.webix.com/pivot-backend/",
override: new Map([[pivot.services.Backend, MyBackend]]),
});
Related sample: Pivot: Local Data
Pivot is flexible: you can change almost anything in it. However, keep in mind the following:
Code for Edge Chromium must use a different syntax.