forked from nikitaeverywhere/LightPivotTable
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
182 lines (166 loc) · 10.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>LightPivot Demos</title>
<!-- build:css -->
<link rel="stylesheet" href="../source/css/LightPivot.css"/>
<!-- endbuild -->
<!-- build:js -->
<script type="text/javascript" src="../source/js/numeral.js"></script>
<script type="text/javascript" src="../source/js/LightPivotTable.js"></script>
<script type="text/javascript" src="../source/js/DataSource.js"></script>
<script type="text/javascript" src="../source/js/PivotView.js"></script>
<script type="text/javascript" src="../source/js/DataController.js"></script>
<script type="text/javascript" src="../source/js/MDXParser.js"></script>
<script type="text/javascript" src="../source/js/PivotLocale.js"></script>
<!-- endbuild -->
<style>
a {
text-decoration: underline;
color: blue;
cursor: pointer;
}
</style>
</head>
<body>
<div id="pivot" style="position: fixed; left: 20%; top: 30%; width: 60%; height: 60%;
box-shadow: 0 0 20px rgb(135, 135, 135);">
</div>
<div>Variants:
<a onclick="rSoon(this)">0</a>,
<a onclick="rSoon(this)">1</a>,
<a onclick="rSoon(this)">2</a>,
<a onclick="rSoon(this)">3</a>,
<a onclick="rSoon(this)">4</a>,
<a onclick="rSoon(this)">5</a>,
<a onclick="rSoon(this)">6</a>,
<a onclick="rSoon(this)">7</a>,
<a onclick="rSoon(this)">8</a>,
<a onclick="rSoon(this)">9</a>,
<a onclick="rSoon(this)">10</a>,
<a onclick="rSoon(this)">11</a>,
<a onclick="rSoon(this)">12</a>,
<a onclick="rSoon(this)">13</a>
</div>
<div id="mdx"></div>
<form id="mdxForm" onsubmit="return false;">
<label>
<br/>Your MDX:<br/>
<input id="yourMDX" type="text" style="width: 100%"/>
</label>
</form>
<!--button onclick="var e = new ExcelExport(); e.exportXLS();">Export to Excel</button-->
<script type="text/javascript">
// reloads the page.
var rSoon = function (o) {
location.hash = "#" + o.textContent;
setTimeout(function () { window.location.reload(true); }, 1);
};
var mdxTo = document.getElementById("mdx"),
v = parseInt(location.hash.slice(1)) || 0,
req = [
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY HEAD(NONEMPTYCROSSJOIN([Outlet].[H1].[Region].Members,[Outlet].[H1].[Country].Members),2000) ON 1 FROM [HoleFoods] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY [DateOfSale].[Actual].[MonthSold].&[201003].children ON 1 FROM [HoleFoods] %FILTER [DateOfSale].[Actual].[YearSold].&[2010] %FILTER [DateOfSale].[Actual].[MonthSold].&[201003] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY HEAD(NONEMPTYCROSSJOIN([DateOfSale].[Actual].[YearSold].Members,[DateOfSale].[Actual].[MonthSold].Members),2000) ON 1 FROM [HoleFoods] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY NONEMPTYCROSSJOIN([Product].[P1].[Product Category].Members,[Product].[P1].[Product Name].Members) ON 0,NON EMPTY HEAD(NONEMPTYCROSSJOIN([DateOfSale].[Actual].[YearSold].Members,[DateOfSale].[Actual].[MonthSold].Members),2000) ON 1 FROM [HoleFoods] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY NONEMPTYCROSSJOIN(NONEMPTYCROSSJOIN([Product].[P1].[Product Category].Members,[Product].[P1].[Product Name].Members),{%LABEL([Measures].[%COUNT],\"Кол-во\",\"\"),[Measures].[Units Sold]}) ON 0,NON EMPTY HEAD(NONEMPTYCROSSJOIN([DateOfSale].[Actual].[YearSold].Members,[DateOfSale].[Actual].[MonthSold].Members),2000) ON 1 FROM [HoleFoods]",
"SELECT {[Measures].[%COUNT]} ON 0 FROM [HoleFoods] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,{[Measures].[%COUNT]} ON 1 FROM [HoleFoods] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0, NON EMPTY [Outlet].[H1].[Region].Members ON 1 FROM [HoleFoods]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY [DateOfSale].[Actual].[YearSold].&[2010].children ON 1 FROM [HoleFoods] %FILTER [DateOfSale].[Actual].[YearSold].&[2010] %FILTER [Measures].[%COUNT]",
"SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY [DateOfSale].[Actual].[YearSold].Members ON 1 FROM [HoleFoods]",
{
basicMDX: "SELECT NON EMPTY [Product].[P1].[Product Category].Members ON 0,NON EMPTY [DateOfSale].[Actual].[YearSold].Members ON 1 FROM [HoleFoods]",
DrillDownExpression: "NONEMPTYCROSSJOIN([Outlet].[H1].[Region].Members,[Outlet].[H1].[Country].Members)"
},
{
basicMDX: "SELECT NON EMPTY [Outlet]" +
".[H1].[Region].Members ON 0,NON EMPTY [DateOfSale].[Actual].[YearSold].Members ON 1 FROM [HoleFoods]",
DrillDownExpression: "NONEMPTYCROSSJOIN([DateOfSale].[Actual].[YearSold].Members,[Product].[P1].[Product Category].Members)"
},
"SELECT NON EMPTY [AgeD].[H1].[Age Group].Members ON 0,NON EMPTY HEAD(NONEMPTYCROSSJOIN([DocD].[H1].[Doctor].Members,[AllerSevD].[H1].[Allergy Severities].Members),2000) ON 1 FROM [Patients]",
{
basicMDX: 'SELECT NON EMPTY {[Measures].[%COUNT],%LABEL([Measures].[Avg Age],"Avg Age (ex. 1)",""),%LABEL([Measures].[Avg Age],"Avg Age (ex. 2)",""),%LABEL([Measures].[Avg Age],"Avg Age (ex. 3)","")} ON 0,NON EMPTY [AllerSevD].[H1].[Allergy Severities].Members ON 1 FROM [Patients]',
pivot: "Pivot Features/Conditional Formatting.pivot"
},
{
basicMDX: 'SELECT NON EMPTY HEAD({NONEMPTYCROSSJOIN([Product].[P1].[Product Category].&[Pasta],[Measures].[Units Sold]),NONEMPTYCROSSJOIN([Product].[P1].[Product Category].&[Pasta],[Measures].[Amount Sold])},2000,SAMPLE) ON 1 FROM [HOLEFOODS]',
pivot: 'OH/Measure labels displayed.pivot'
},
{
basicMDX: 'SELECT NON EMPTY HEAD({NONEMPTYCROSSJOIN([Product].[P1].[Product Category].&[Pasta],[Measures].[Units Sold]),NONEMPTYCROSSJOIN([Product].[P1].[Product Category].&[Pasta],[Measures].[Amount Sold])},2000,SAMPLE) ON 1 FROM [HOLEFOODS]',
pivot: 'OH/Measure labels ommitted.pivot'
}
][v],
setup;
if (location.hash.slice(1, 3) === "q=") {
req = location.hash.slice(3);
}
setup = {
container: document.getElementById("pivot") // HTMLElement which will contain table.
//, locale: "en" // language to use (default: browser default or "en")
, dataSource: {
MDX2JSONSource: "http://" + location.hostname + ":57772/MDX2JSON"
//MDX2JSONSource: "http://37.139.4.54/MDX2JSON"
// MDX2JSON server address
, basicMDX: typeof req === "object" ? req.basicMDX : req
//, pivot: "name of data source.pivot" // name of data source to apply pivot rules
, namespace: "SAMPLES" // current namespace : default namespace
, username: "_SYSTEM" // user name : default user
, password: "SYS" // user password : default password
}
, triggers: { //
// drillDown: function ({Object { level: {number}, mdx: {string} }}) {}
//, drillThrough: function ({Object { level: {number}, mdx: {string} }}) {}
//, back: function ({Object { level: {number} }}) {}
// if cellDrillThrough callback returns boolean false, DrillThrough won't be performed.
//, cellDrillThrough: function ({Object { event: {event}, filters: {string[]} }}) {}
//, rowSelect: function (rs) { console.log("Rows: ", rs); }
//, contentRendered: function () { console.log("Rendered, wow!"); }
}
, pagination: 30 // Maximum rows number on one page (default: 200, turn off: 0)
//, hideButtons: true // hides "back" and "drillThrough" buttons
//, triggerEvent: "touchstart" // all "click" events will be replaced by this event
//, caption: "My table" // if set, table basic caption will be replaced by this text
, showSummary: true // show summary by columns
//, attachTotals: true // display totals attached to table top header
//, enableHeadersScrolling: true // enable scrolling both for table and headers
//, loadingMessageHTML: "LOADING DATA..." // HTML displaying during data load
//, conditionalFormattingOn: true // enable conditional formatting rules
//, defaultFilterSpecs: ["[Date].[H1].[month].&[]"] ] // default filters array
//, drillDownTarget: "<dashboard name>" // undocumented, deepSee only
//, listingColumnMinWidth: 200 // minimal width of column in listing
//, maxHeaderWidth: 100 // maximum width of header
//, columnResizing: true // make columns resizable (default: true)
//, enableSearch: false // enables search panel in listing
//, stretchColumns: true // stretch columns to fill all available width (default: true)
//, showRowNumbers: true // show the row number in first column
//, enableListingSelect: true // enable selection in listing
};
var e;
if (req.DrillDownExpression) { // set custom DrillDown on variant 10
setup.DrillDownExpression = req.DrillDownExpression;
e = document.createElement("div");
e.innerHTML = "<b>Custom DrillDown expression set up here: </b>"
+ setup.DrillDownExpression;
document.getElementById("mdxForm").appendChild(e);
}
if (req.pivot) {
setup.dataSource.pivot = req.pivot;
e = document.createElement("div");
e.innerHTML = "<b>Pivot attached here: </b>"
+ req.pivot;
document.getElementById("mdxForm").appendChild(e);
}
document.getElementById("mdxForm").addEventListener("submit", function () {
var yourMDX = document.getElementById("yourMDX").value;
window.location.hash = "#q=" + yourMDX;
window.location.reload(true);
});
mdxTo.innerHTML = "<b>Basic MDX:</b> <i>" + (typeof req === "object" ? req.basicMDX : req)
+ "</i>";
var lp = new LightPivotTable(setup); // create widget
</script>
</body>
</html>