├── .gitignore ├── Hands-on Steps Profile ├── Profile Step 0 - Hello WebComponent │ └── index.html ├── Profile Step 1 - Hello Custom Widget │ ├── index.json │ ├── main copy.js │ ├── main.js │ └── main.js.zip ├── Profile Step 2 - Integrated lifecycle functions │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 3 - Adding Data Binding │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 4 - Rendering bound data with echarts │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 5 - Add Properties and Functions │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 6 - Add Events and integrate with Click-events from ECharts │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 7 - Add Custom Data Types │ ├── index.json │ ├── main.js │ └── main.js.zip ├── Profile Step 8 - Add Custom Styling Panel │ ├── Archive.zip │ ├── index.json │ ├── main.js │ └── styling.js └── Profile Step 9 - Calculate Integrity │ ├── Archive.zip │ ├── build │ └── sign.js │ ├── index.json │ ├── main.js │ └── styling.js ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md └── REUSE.toml /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 0 - Hello WebComponent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 1 - Hello Custom Widget/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.xxx", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-xxx-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | } 29 | }, 30 | "methods":{}, 31 | "events":{} 32 | } 33 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 1 - Hello Custom Widget/main copy.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve); 4 | }); 5 | }; 6 | (function () { 7 | const template = document.createElement('template') 8 | template.innerHTML = ` 9 | 11 |
12 | Hello Custom Widget 13 |
14 | ` 15 | class Main extends HTMLElement { 16 | constructor () { 17 | super() 18 | 19 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 20 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 21 | 22 | this._root = this._shadowRoot.getElementById('root') 23 | } 24 | } 25 | 26 | customElements.define('com-sap-sac-exercise-xxx-main', Main) 27 | })() 28 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 1 - Hello Custom Widget/main.js: -------------------------------------------------------------------------------- 1 | 2 | (function () { 3 | const template = document.createElement('template') 4 | template.innerHTML = ` 5 | 7 |
8 | Hello Custom Widget 9 |
10 | ` 11 | class Main extends HTMLElement { 12 | constructor () { 13 | super() 14 | 15 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 16 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 17 | 18 | this._root = this._shadowRoot.getElementById('root') 19 | } 20 | } 21 | 22 | customElements.define('com-sap-sac-exercise-xxx-main', Main) 23 | })() 24 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 1 - Hello Custom Widget/main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 1 - Hello Custom Widget/main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 2 - Integrated lifecycle functions/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | } 29 | }, 30 | "methods":{}, 31 | "events":{} 32 | } 33 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 2 - Integrated lifecycle functions/main.js: -------------------------------------------------------------------------------- 1 | 2 | (function () { 3 | const template = document.createElement('template') 4 | template.innerHTML = ` 5 | 7 |
8 | Hello Custom Widget 9 |
10 | ` 11 | class Main extends HTMLElement { 12 | constructor () { 13 | super() 14 | 15 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 16 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 17 | 18 | this._root = this._shadowRoot.getElementById('root') 19 | } 20 | 21 | onCustomWidgetResize (width, height) { 22 | this.render() 23 | } 24 | 25 | onCustomWidgetAfterUpdate (changedProps) { 26 | } 27 | 28 | onCustomWidgetDestroy () { 29 | } 30 | 31 | render () { 32 | this._root.textContent = `Hello Custom Widget clientWidth: ${this.clientWidth}, clientHeight: ${this.clientHeight}` 33 | } 34 | } 35 | 36 | customElements.define('com-sap-sac-exercise-username-main', Main) 37 | })() 38 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 2 - Integrated lifecycle functions/main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 2 - Integrated lifecycle functions/main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 3 - Adding Data Binding/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | } 29 | }, 30 | "methods":{}, 31 | "events":{}, 32 | "dataBindings": { 33 | "dataBinding": { 34 | "feeds": [ 35 | { 36 | "id": "dimensions", 37 | "description": "Dimensions", 38 | "type": "dimension" 39 | }, 40 | { 41 | "id": "measures", 42 | "description": "Measures", 43 | "type": "mainStructureMember" 44 | } 45 | ] 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 3 - Adding Data Binding/main.js: -------------------------------------------------------------------------------- 1 | 2 | (function () { 3 | const template = document.createElement('template') 4 | template.innerHTML = ` 5 | 7 |
8 | Hello Custom Widget 9 |
10 | ` 11 | class Main extends HTMLElement { 12 | constructor () { 13 | super() 14 | 15 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 16 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 17 | 18 | this._root = this._shadowRoot.getElementById('root') 19 | } 20 | 21 | onCustomWidgetResize (width, height) { 22 | this.render() 23 | } 24 | 25 | onCustomWidgetAfterUpdate (changedProps) { 26 | this.render() 27 | } 28 | 29 | onCustomWidgetDestroy () { 30 | } 31 | 32 | async render () { 33 | const dataBinding = this.dataBinding 34 | if (!dataBinding || dataBinding.state !== 'success') { 35 | return 36 | } 37 | this._root.textContent = JSON.stringify(dataBinding) 38 | } 39 | } 40 | 41 | customElements.define('com-sap-sac-exercise-username-main', Main) 42 | })() 43 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 3 - Adding Data Binding/main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 3 - Adding Data Binding/main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 4 - Rendering bound data with echarts /index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | } 29 | }, 30 | "methods":{}, 31 | "events":{}, 32 | "dataBindings": { 33 | "dataBinding": { 34 | "feeds": [ 35 | { 36 | "id": "dimensions", 37 | "description": "Dimensions", 38 | "type": "dimension" 39 | }, 40 | { 41 | "id": "measures", 42 | "description": "Measures", 43 | "type": "mainStructureMember" 44 | } 45 | ] 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 4 - Rendering bound data with echarts /main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | } 41 | 42 | onCustomWidgetResize (width, height) { 43 | this.render() 44 | } 45 | 46 | onCustomWidgetAfterUpdate (changedProps) { 47 | this.render() 48 | } 49 | 50 | 51 | onCustomWidgetDestroy () { 52 | 53 | } 54 | 55 | async render () { 56 | const dataBinding = this.dataBinding 57 | if (!dataBinding || dataBinding.state !== 'success') { return } 58 | 59 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 60 | 61 | const { data, metadata } = dataBinding 62 | const { dimensions, measures } = parseMetadata(metadata) 63 | // dimension 64 | const categoryData = [] 65 | 66 | // measures 67 | const series = measures.map(measure => { 68 | return { 69 | id: measure.id, 70 | name: measure.label, 71 | data: [], 72 | key: measure.key, 73 | type: 'line', 74 | smooth: true 75 | } 76 | }) 77 | 78 | data.forEach(row => { 79 | categoryData.push(dimensions.map(dimension => { 80 | return row[dimension.key].label 81 | }).join('/')) // dimension 82 | series.forEach(series => { 83 | series.data.push(row[series.key].raw) 84 | }) // measures 85 | }) 86 | 87 | if (this._eChart) { echarts.dispose(this._eChart) } 88 | const eChart = this._eChart = echarts.init(this._root, 'main') 89 | const option = { 90 | xAxis: { type: 'category', data: categoryData }, 91 | yAxis: { type: 'value' }, 92 | tooltip: { trigger: 'axis' }, 93 | series 94 | } 95 | eChart.setOption(option) 96 | } 97 | } 98 | 99 | customElements.define('com-sap-sac-exercise-username-main', Main) 100 | })() 101 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 4 - Rendering bound data with echarts /main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 4 - Rendering bound data with echarts /main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 5 - Add Properties and Functions /index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | }, 29 | "seriesType": { 30 | "type": "string", 31 | "default": "line", 32 | "description": "Series type" 33 | } 34 | }, 35 | "methods": { 36 | "setSeriesType": { 37 | "description": "Set series type", 38 | "parameters": [ 39 | { 40 | "name": "value", 41 | "type": "string", 42 | "description": "Series type" 43 | } 44 | ] 45 | } 46 | }, 47 | "events":{}, 48 | "dataBindings": { 49 | "dataBinding": { 50 | "feeds": [ 51 | { 52 | "id": "dimensions", 53 | "description": "Dimensions", 54 | "type": "dimension" 55 | }, 56 | { 57 | "id": "measures", 58 | "description": "Measures", 59 | "type": "mainStructureMember" 60 | } 61 | ] 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 5 - Add Properties and Functions /main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | } 41 | 42 | onCustomWidgetResize (width, height) { 43 | this.render() 44 | } 45 | 46 | onCustomWidgetAfterUpdate (changedProps) { 47 | this.render() 48 | } 49 | 50 | onCustomWidgetDestroy () { 51 | if (this._eChart && echarts) { echarts.dispose(this._eChart) } 52 | } 53 | 54 | setSeriesType (seriesType) { 55 | this.seriesType = seriesType 56 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 57 | this.render() 58 | } 59 | 60 | async render () { 61 | const dataBinding = this.dataBinding 62 | if (!dataBinding || dataBinding.state !== 'success') { return } 63 | 64 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 65 | 66 | const { data, metadata } = dataBinding 67 | const { dimensions, measures } = parseMetadata(metadata) 68 | // dimension 69 | const categoryData = [] 70 | 71 | // measures 72 | const series = measures.map(measure => { 73 | return { 74 | id: measure.id, 75 | name: measure.label, 76 | data: [], 77 | key: measure.key, 78 | type: this.seriesType || 'line', 79 | smooth: true 80 | } 81 | }) 82 | 83 | data.forEach(row => { 84 | categoryData.push(dimensions.map(dimension => { 85 | return row[dimension.key].label 86 | }).join('/')) // dimension 87 | series.forEach(series => { 88 | series.data.push(row[series.key].raw) 89 | }) // measures 90 | }) 91 | 92 | if (this._eChart) { echarts.dispose(this._eChart) } 93 | const eChart = this._eChart = echarts.init(this._root, 'main') 94 | const option = { 95 | xAxis: { type: 'category', data: categoryData }, 96 | yAxis: { type: 'value' }, 97 | tooltip: { trigger: 'axis' }, 98 | series 99 | } 100 | eChart.setOption(option) 101 | } 102 | } 103 | 104 | customElements.define('com-sap-sac-exercise-username-main', Main) 105 | })() 106 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 5 - Add Properties and Functions /main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 5 - Add Properties and Functions /main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 6 - Add Events and integrate with Click-events from ECharts/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | } 19 | ], 20 | "properties": { 21 | "width": { 22 | "type": "integer", 23 | "default": 600 24 | }, 25 | "height": { 26 | "type": "integer", 27 | "default": 420 28 | }, 29 | "seriesType": { 30 | "type": "string", 31 | "default": "line", 32 | "description": "Series type" 33 | } 34 | }, 35 | "methods": { 36 | "setSeriesType": { 37 | "description": "Set series type", 38 | "parameters": [ 39 | { 40 | "name": "value", 41 | "type": "string", 42 | "description": "Series type" 43 | } 44 | ] 45 | } 46 | }, 47 | "events": { 48 | "onClick": { 49 | "description": "Dispatch when user click a data point on eChart" 50 | } 51 | }, 52 | "dataBindings": { 53 | "dataBinding": { 54 | "feeds": [ 55 | { 56 | "id": "dimensions", 57 | "description": "Dimensions", 58 | "type": "dimension" 59 | }, 60 | { 61 | "id": "measures", 62 | "description": "Measures", 63 | "type": "mainStructureMember" 64 | } 65 | ] 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 6 - Add Events and integrate with Click-events from ECharts/main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | } 41 | 42 | onCustomWidgetResize (width, height) { 43 | this.render() 44 | } 45 | 46 | onCustomWidgetAfterUpdate (changedProps) { 47 | this.render() 48 | } 49 | 50 | onCustomWidgetDestroy () { 51 | if (this._eChart && echarts) { echarts.dispose(this._eChart) } 52 | } 53 | 54 | setSeriesType (seriesType) { 55 | this.seriesType = seriesType 56 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 57 | this.render() 58 | } 59 | 60 | async render () { 61 | const dataBinding = this.dataBinding 62 | if (!dataBinding || dataBinding.state !== 'success') { return } 63 | 64 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 65 | 66 | const { data, metadata } = dataBinding 67 | const { dimensions, measures } = parseMetadata(metadata) 68 | // dimension 69 | const categoryData = [] 70 | 71 | // measures 72 | const series = measures.map(measure => { 73 | return { 74 | id: measure.id, 75 | name: measure.label, 76 | data: [], 77 | key: measure.key, 78 | type: this.seriesType || 'line', 79 | smooth: true 80 | } 81 | }) 82 | 83 | data.forEach(row => { 84 | categoryData.push(dimensions.map(dimension => { 85 | return row[dimension.key].label 86 | }).join('/')) // dimension 87 | series.forEach(series => { 88 | series.data.push(row[series.key].raw) 89 | }) // measures 90 | }) 91 | 92 | if (this._eChart) { echarts.dispose(this._eChart) } 93 | const eChart = this._eChart = echarts.init(this._root, 'main') 94 | const option = { 95 | xAxis: { type: 'category', data: categoryData }, 96 | yAxis: { type: 'value' }, 97 | tooltip: { trigger: 'axis' }, 98 | series 99 | } 100 | eChart.setOption(option) 101 | eChart.on('click', (params) => { 102 | // https://echarts.apache.org/en/api.html#events.Mouse%20events 103 | this.dispatchEvent(new Event('onClick')) 104 | }) 105 | } 106 | } 107 | 108 | customElements.define('com-sap-sac-exercise-username-main', Main) 109 | })() 110 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 6 - Add Events and integrate with Click-events from ECharts/main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 6 - Add Events and integrate with Click-events from ECharts/main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 7 - Add Custom Data Types/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | 19 | } 20 | ], 21 | "properties": { 22 | "width": { 23 | "type": "integer", 24 | "default": 600 25 | }, 26 | "height": { 27 | "type": "integer", 28 | "default": 420 29 | }, 30 | "seriesType": { 31 | "type": "string", 32 | "default": "line", 33 | "description": "Series type" 34 | } 35 | }, 36 | "methods": { 37 | "setSeriesType": { 38 | "description": "Set series type", 39 | "parameters": [ 40 | { 41 | "name": "value", 42 | "type": "string", 43 | "description": "Series type" 44 | } 45 | ] 46 | }, 47 | "getSelectedDataPoint": { 48 | "description": "Get selected data point", 49 | "returnType": "EChartDataPoint" 50 | } 51 | }, 52 | "events": { 53 | "onClick": { 54 | "description": "Dispatch when user click a data point on eChart" 55 | } 56 | }, 57 | "types": { 58 | "EChartDataPoint": { 59 | "description": "EChart data point", 60 | "properties": [ 61 | { 62 | "name": "seriesIndex", 63 | "type": "integer", 64 | "description": "series index in incoming option.series (make sense when componentType is 'series')" 65 | }, 66 | { 67 | "name": "seriesName", 68 | "type": "string", 69 | "description": "series name (make sense when componentType is 'series')" 70 | }, 71 | { 72 | "name": "dataIndex", 73 | "type": "integer", 74 | "description": "data index in input data array" 75 | }, 76 | { 77 | "name": "data", 78 | "type": "number", 79 | "description": "data value" 80 | }, 81 | { 82 | "name": "name", 83 | "type": "string", 84 | "description": "data name, or category name" 85 | } 86 | ] 87 | } 88 | }, 89 | "dataBindings": { 90 | "dataBinding": { 91 | "feeds": [ 92 | { 93 | "id": "dimensions", 94 | "description": "Dimensions", 95 | "type": "dimension" 96 | }, 97 | { 98 | "id": "measures", 99 | "description": "Measures", 100 | "type": "mainStructureMember" 101 | } 102 | ] 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 7 - Add Custom Data Types/main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | this._selectedDataPoint = {} 41 | } 42 | 43 | onCustomWidgetResize (width, height) { 44 | this.render() 45 | } 46 | 47 | onCustomWidgetAfterUpdate (changedProps) { 48 | this.render() 49 | } 50 | 51 | onCustomWidgetDestroy () { 52 | if (this._eChart && echarts) { echarts.dispose(this._eChart) } 53 | } 54 | 55 | setSeriesType (seriesType) { 56 | this.seriesType = seriesType 57 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 58 | this.render() 59 | } 60 | 61 | getSelectedDataPoint () { 62 | return this._selectedDataPoint 63 | } 64 | 65 | async render () { 66 | const dataBinding = this.dataBinding 67 | if (!dataBinding || dataBinding.state !== 'success') { return } 68 | 69 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 70 | 71 | const { data, metadata } = dataBinding 72 | const { dimensions, measures } = parseMetadata(metadata) 73 | // dimension 74 | const categoryData = [] 75 | 76 | // measures 77 | const series = measures.map(measure => { 78 | return { 79 | id: measure.id, 80 | name: measure.label, 81 | data: [], 82 | key: measure.key, 83 | type: this.seriesType || 'line', 84 | smooth: true 85 | } 86 | }) 87 | 88 | data.forEach(row => { 89 | categoryData.push(dimensions.map(dimension => { 90 | return row[dimension.key].label 91 | }).join('/')) // dimension 92 | series.forEach(series => { 93 | series.data.push(row[series.key].raw) 94 | }) // measures 95 | }) 96 | 97 | if (this._eChart) { echarts.dispose(this._eChart) } 98 | const eChart = this._eChart = echarts.init(this._root, 'main') 99 | const option = { 100 | xAxis: { type: 'category', data: categoryData }, 101 | yAxis: { type: 'value' }, 102 | tooltip: { trigger: 'axis' }, 103 | series 104 | } 105 | eChart.setOption(option) 106 | eChart.on('click', (params) => { 107 | // https://echarts.apache.org/en/api.html#events.Mouse%20events 108 | const { seriesIndex, seriesName, dataIndex, data, name } = params 109 | this._selectedDataPoint = { seriesIndex, seriesName, dataIndex, data, name } 110 | this.dispatchEvent(new Event('onClick')) 111 | }) 112 | } 113 | } 114 | 115 | customElements.define('com-sap-sac-exercise-username-main', Main) 116 | })() 117 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 7 - Add Custom Data Types/main.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 7 - Add Custom Data Types/main.js.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 8 - Add Custom Styling Panel/Archive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 8 - Add Custom Styling Panel/Archive.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 8 - Add Custom Styling Panel/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "", 17 | "ignoreIntegrity": true 18 | }, 19 | { 20 | "kind": "styling", 21 | "tag": "com-sap-sac-exercise-username-styling", 22 | "url": "/styling.js", 23 | "integrity": "", 24 | "ignoreIntegrity": true 25 | } 26 | ], 27 | "properties": { 28 | "width": { 29 | "type": "integer", 30 | "default": 600 31 | }, 32 | "height": { 33 | "type": "integer", 34 | "default": 420 35 | }, 36 | "seriesType": { 37 | "type": "string", 38 | "default": "line", 39 | "description": "Series type" 40 | } 41 | }, 42 | "methods": { 43 | "setSeriesType": { 44 | "description": "Set series type", 45 | "parameters": [ 46 | { 47 | "name": "value", 48 | "type": "string", 49 | "description": "Series type" 50 | } 51 | ] 52 | }, 53 | "getSelectedDataPoint": { 54 | "description": "Get selected data point", 55 | "returnType": "EChartDataPoint" 56 | } 57 | }, 58 | "events": { 59 | "onClick": { 60 | "description": "Dispatch when user click a data point on eChart" 61 | } 62 | }, 63 | "types": { 64 | "EChartDataPoint": { 65 | "description": "EChart data point", 66 | "properties": [ 67 | { 68 | "name": "seriesIndex", 69 | "type": "integer", 70 | "description": "series index in incoming option.series (make sense when componentType is 'series')" 71 | }, 72 | { 73 | "name": "seriesName", 74 | "type": "string", 75 | "description": "series name (make sense when componentType is 'series')" 76 | }, 77 | { 78 | "name": "dataIndex", 79 | "type": "integer", 80 | "description": "data index in input data array" 81 | }, 82 | { 83 | "name": "data", 84 | "type": "number", 85 | "description": "data value" 86 | }, 87 | { 88 | "name": "name", 89 | "type": "string", 90 | "description": "data name, or category name" 91 | } 92 | ] 93 | } 94 | }, 95 | "dataBindings": { 96 | "dataBinding": { 97 | "feeds": [ 98 | { 99 | "id": "dimensions", 100 | "description": "Dimensions", 101 | "type": "dimension" 102 | }, 103 | { 104 | "id": "measures", 105 | "description": "Measures", 106 | "type": "mainStructureMember" 107 | } 108 | ] 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 8 - Add Custom Styling Panel/main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | this._selectedDataPoint = {} 41 | } 42 | 43 | onCustomWidgetResize (width, height) { 44 | this.render() 45 | } 46 | 47 | onCustomWidgetAfterUpdate (changedProps) { 48 | this.render() 49 | } 50 | 51 | onCustomWidgetDestroy () { 52 | if (this._eChart && echarts) { echarts.dispose(this._eChart) } 53 | } 54 | 55 | setSeriesType (seriesType) { 56 | this.seriesType = seriesType 57 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 58 | this.render() 59 | } 60 | 61 | getSelectedDataPoint () { 62 | return this._selectedDataPoint 63 | } 64 | 65 | async render () { 66 | const dataBinding = this.dataBinding 67 | if (!dataBinding || dataBinding.state !== 'success') { return } 68 | 69 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 70 | 71 | const { data, metadata } = dataBinding 72 | const { dimensions, measures } = parseMetadata(metadata) 73 | // dimension 74 | const categoryData = [] 75 | 76 | // measures 77 | const series = measures.map(measure => { 78 | return { 79 | id: measure.id, 80 | name: measure.label, 81 | data: [], 82 | key: measure.key, 83 | type: this.seriesType || 'line', 84 | smooth: true 85 | } 86 | }) 87 | 88 | data.forEach(row => { 89 | categoryData.push(dimensions.map(dimension => { 90 | return row[dimension.key].label 91 | }).join('/')) // dimension 92 | series.forEach(series => { 93 | series.data.push(row[series.key].raw) 94 | }) // measures 95 | }) 96 | 97 | if (this._eChart) { echarts.dispose(this._eChart) } 98 | const eChart = this._eChart = echarts.init(this._root, 'main') 99 | const option = { 100 | xAxis: { type: 'category', data: categoryData }, 101 | yAxis: { type: 'value' }, 102 | tooltip: { trigger: 'axis' }, 103 | series 104 | } 105 | eChart.setOption(option) 106 | eChart.on('click', (params) => { 107 | // https://echarts.apache.org/en/api.html#events.Mouse%20events 108 | const { seriesIndex, seriesName, dataIndex, data, name } = params 109 | this._selectedDataPoint = { seriesIndex, seriesName, dataIndex, data, name } 110 | this.dispatchEvent(new Event('onClick')) 111 | }) 112 | } 113 | } 114 | 115 | customElements.define('com-sap-sac-exercise-username-main', Main) 116 | })() 117 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 8 - Add Custom Styling Panel/styling.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | const template = document.createElement('template') 3 | template.innerHTML = ` 4 | 23 |
24 | 25 | 29 | 30 | 31 |
32 | ` 33 | 34 | class Styling extends HTMLElement { 35 | constructor () { 36 | super() 37 | 38 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 39 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 40 | this._root = this._shadowRoot.getElementById('root') 41 | 42 | this._button = this._shadowRoot.getElementById('button') 43 | this._button.addEventListener('click', () => { 44 | const seriesType = this._shadowRoot.getElementById('seriesType-dropdown').value 45 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 46 | }) 47 | } 48 | 49 | async onCustomWidgetAfterUpdate (changedProps) { 50 | if (changedProps.seriesType) { 51 | let seriesType = changedProps.seriesType 52 | if (seriesType !== 'line' && seriesType !== 'bar') { seriesType = 'line' } 53 | this._shadowRoot.getElementById('seriesType-dropdown').value = seriesType 54 | } 55 | } 56 | } 57 | 58 | customElements.define('com-sap-sac-exercise-username-styling', Styling) 59 | })() 60 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /Archive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/analytics-cloud-custom-widget/9f37ee1012681e6121a668038e97c9d021eaacd6/Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /Archive.zip -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /build/sign.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const { createHash } = require('crypto') 3 | const path = require('path') 4 | 5 | const run = js => { 6 | const hashSha256 = createHash('sha256') 7 | const input = fs.createReadStream(path.join(__dirname, '../', js)) 8 | input.on('readable', () => { 9 | const data = input.read() 10 | if (data) { 11 | hashSha256.update(data) 12 | } else { 13 | const integrity = `sha256-${hashSha256.digest('base64')}` 14 | console.log(`${js}: ${integrity}`) 15 | } 16 | }) 17 | } 18 | 19 | [ 20 | 'main.js', 21 | 'styling.js' 22 | ].forEach(js => run(js)) 23 | // main.js: sha256-MeTdl0DMaTJcaQnYlp5Tf96vDT+pdAewY19VdbZOs4Q= 24 | // styling.js: sha256-8AykY9bAoqb0rMOoG3kR6XtPhpLlmKLgIvznx/eeNio= 25 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /index.json: -------------------------------------------------------------------------------- 1 | { 2 | "eula": "", 3 | "vendor": "SAP", 4 | "license": "", 5 | "id": "com.sap.sac.exercise.username", 6 | "version": "1.0.0", 7 | "name": "Guided Custom Widget Exercise", 8 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAzklEQVQ4jWNgoBAwkqLYOLGjguH//1RGxv+7z8yvymBgYGBgIcm2//8lGRgZlP7/Z5CDiTGRYgA2QLEBOL2gFVrPxsXDYcfAwMDw7cuPQ9dWN/4iyQBebi75vwz/dkPZagwMDLexqaOeF4wT2jcyMjL4Mfz/33tmQVUJsQYgueA/K4RmZCXFBQMfjQNvADwWGBkZHv3/z3CPgZHxOQMDAwPjv9/fGJiZ7sLZDAwM/xkZnzP8/3+PkZHhEaUWwwGjSWL7f0oMYGFgYFCmxAAACtUz95booNoAAAAASUVORK5CYII=", 9 | "newInstancePrefix": "ExerciseCustomWidget", 10 | "description": "A Guided Custom Widget Exercise", 11 | "webcomponents": [ 12 | { 13 | "kind": "main", 14 | "tag": "com-sap-sac-exercise-username-main", 15 | "url": "/main.js", 16 | "integrity": "sha256-MeTdl0DMaTJcaQnYlp5Tf96vDT+pdAewY19VdbZOs4Q=", 17 | "ignoreIntegrity": false 18 | }, 19 | { 20 | "kind": "styling", 21 | "tag": "com-sap-sac-exercise-username-styling", 22 | "url": "/styling.js", 23 | "integrity": "sha256-loFN9YrBl6ZeK8b9dvAbpK7lXdxWOxZYE3CqdXLN5JQ=", 24 | "ignoreIntegrity": false 25 | } 26 | ], 27 | "properties": { 28 | "width": { 29 | "type": "integer", 30 | "default": 600 31 | }, 32 | "height": { 33 | "type": "integer", 34 | "default": 420 35 | }, 36 | "seriesType": { 37 | "type": "string", 38 | "default": "line", 39 | "description": "Series type" 40 | } 41 | }, 42 | "methods": { 43 | "setSeriesType": { 44 | "description": "Set series type", 45 | "parameters": [ 46 | { 47 | "name": "value", 48 | "type": "string", 49 | "description": "Series type" 50 | } 51 | ] 52 | }, 53 | "getSelectedDataPoint": { 54 | "description": "Get selected data point", 55 | "returnType": "EChartDataPoint" 56 | } 57 | }, 58 | "events": { 59 | "onClick": { 60 | "description": "Dispatch when user click a data point on eChart" 61 | } 62 | }, 63 | "types": { 64 | "EChartDataPoint": { 65 | "description": "EChart data point", 66 | "properties": [ 67 | { 68 | "name": "seriesIndex", 69 | "type": "integer", 70 | "description": "series index in incoming option.series (make sense when componentType is 'series')" 71 | }, 72 | { 73 | "name": "seriesName", 74 | "type": "string", 75 | "description": "series name (make sense when componentType is 'series')" 76 | }, 77 | { 78 | "name": "dataIndex", 79 | "type": "integer", 80 | "description": "data index in input data array" 81 | }, 82 | { 83 | "name": "data", 84 | "type": "number", 85 | "description": "data value" 86 | }, 87 | { 88 | "name": "name", 89 | "type": "string", 90 | "description": "data name, or category name" 91 | } 92 | ] 93 | } 94 | }, 95 | "dataBindings": { 96 | "dataBinding": { 97 | "feeds": [ 98 | { 99 | "id": "dimensions", 100 | "description": "Dimensions", 101 | "type": "dimension" 102 | }, 103 | { 104 | "id": "measures", 105 | "description": "Measures", 106 | "type": "mainStructureMember" 107 | } 108 | ] 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /main.js: -------------------------------------------------------------------------------- 1 | var getScriptPromisify = (src) => { 2 | return new Promise((resolve) => { 3 | $.getScript(src, resolve) 4 | }) 5 | } 6 | 7 | var parseMetadata = metadata => { 8 | const { dimensions: dimensionsMap, mainStructureMembers: measuresMap } = metadata 9 | const dimensions = [] 10 | for (const key in dimensionsMap) { 11 | const dimension = dimensionsMap[key] 12 | dimensions.push({ key, ...dimension }) 13 | } 14 | const measures = [] 15 | for (const key in measuresMap) { 16 | const measure = measuresMap[key] 17 | measures.push({ key, ...measure }) 18 | } 19 | return { dimensions, measures, dimensionsMap, measuresMap } 20 | } 21 | 22 | (function () { 23 | const template = document.createElement('template') 24 | template.innerHTML = ` 25 | 27 |
28 |
29 | ` 30 | class Main extends HTMLElement { 31 | constructor () { 32 | super() 33 | 34 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 35 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 36 | 37 | this._root = this._shadowRoot.getElementById('root') 38 | 39 | this._eChart = null 40 | this._selectedDataPoint = {} 41 | } 42 | 43 | onCustomWidgetResize (width, height) { 44 | this.render() 45 | } 46 | 47 | onCustomWidgetAfterUpdate (changedProps) { 48 | this.render() 49 | } 50 | 51 | onCustomWidgetDestroy () { 52 | if (this._eChart && echarts) { echarts.dispose(this._eChart) } 53 | } 54 | 55 | setSeriesType (seriesType) { 56 | this.seriesType = seriesType 57 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 58 | this.render() 59 | } 60 | 61 | getSelectedDataPoint () { 62 | return this._selectedDataPoint 63 | } 64 | 65 | async render () { 66 | const dataBinding = this.dataBinding 67 | if (!dataBinding || dataBinding.state !== 'success') { return } 68 | 69 | await getScriptPromisify('https://cdn.staticfile.org/echarts/5.0.0/echarts.min.js') 70 | 71 | const { data, metadata } = dataBinding 72 | const { dimensions, measures } = parseMetadata(metadata) 73 | // dimension 74 | const categoryData = [] 75 | 76 | // measures 77 | const series = measures.map(measure => { 78 | return { 79 | id: measure.id, 80 | name: measure.label, 81 | data: [], 82 | key: measure.key, 83 | type: this.seriesType || 'line', 84 | smooth: true 85 | } 86 | }) 87 | 88 | data.forEach(row => { 89 | categoryData.push(dimensions.map(dimension => { 90 | return row[dimension.key].label 91 | }).join('/')) // dimension 92 | series.forEach(series => { 93 | series.data.push(row[series.key].raw) 94 | }) // measures 95 | }) 96 | 97 | if (this._eChart) { echarts.dispose(this._eChart) } 98 | const eChart = this._eChart = echarts.init(this._root, 'main') 99 | const option = { 100 | xAxis: { type: 'category', data: categoryData }, 101 | yAxis: { type: 'value' }, 102 | tooltip: { trigger: 'axis' }, 103 | series 104 | } 105 | eChart.setOption(option) 106 | eChart.on('click', (params) => { 107 | // https://echarts.apache.org/en/api.html#events.Mouse%20events 108 | const { seriesIndex, seriesName, dataIndex, data, name } = params 109 | this._selectedDataPoint = { seriesIndex, seriesName, dataIndex, data, name } 110 | this.dispatchEvent(new Event('onClick')) 111 | }) 112 | } 113 | } 114 | 115 | customElements.define('com-sap-sac-exercise-andreawang-main', Main) 116 | })() 117 | -------------------------------------------------------------------------------- /Hands-on Steps Profile/Profile Step 9 - Calculate Integrity /styling.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | const template = document.createElement('template') 3 | template.innerHTML = ` 4 | 23 |
24 | 25 | 29 | 30 | 31 |
32 | ` 33 | 34 | class Styling extends HTMLElement { 35 | constructor () { 36 | super() 37 | 38 | this._shadowRoot = this.attachShadow({ mode: 'open' }) 39 | this._shadowRoot.appendChild(template.content.cloneNode(true)) 40 | this._root = this._shadowRoot.getElementById('root') 41 | 42 | this._button = this._shadowRoot.getElementById('button') 43 | this._button.addEventListener('click', () => { 44 | const seriesType = this._shadowRoot.getElementById('seriesType-dropdown').value 45 | this.dispatchEvent(new CustomEvent('propertiesChanged', { detail: { properties: { seriesType } } })) 46 | }) 47 | } 48 | 49 | async onCustomWidgetAfterUpdate (changedProps) { 50 | if (changedProps.seriesType) { 51 | let seriesType = changedProps.seriesType 52 | if (seriesType !== 'line' && seriesType !== 'bar') { seriesType = 'line' } 53 | this._shadowRoot.getElementById('seriesType-dropdown').value = seriesType 54 | } 55 | } 56 | } 57 | 58 | customElements.define('com-sap-sac-exercise-andreawang-styling', Styling) 59 | })() 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 30 | 31 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 32 | 33 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 34 | 35 | (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and 36 | 37 | (b) You must cause any modified files to carry prominent notices stating that You changed the files; and 38 | 39 | (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 40 | 41 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 42 | 43 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 44 | 45 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 46 | 47 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 48 | 49 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 50 | 51 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 52 | 53 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 54 | 55 | END OF TERMS AND CONDITIONS 56 | 57 | APPENDIX: How to apply the Apache License to your work. 58 | 59 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 60 | 61 | Copyright [yyyy] [name of copyright owner] 62 | 63 | Licensed under the Apache License, Version 2.0 (the "License"); 64 | you may not use this file except in compliance with the License. 65 | You may obtain a copy of the License at 66 | 67 | http://www.apache.org/licenses/LICENSE-2.0 68 | 69 | Unless required by applicable law or agreed to in writing, software 70 | distributed under the License is distributed on an "AS IS" BASIS, 71 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 72 | See the License for the specific language governing permissions and 73 | limitations under the License. 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/analytics-cloud-custom-widget)](https://api.reuse.software/info/github.com/SAP-samples/analytics-cloud-custom-widget) 2 | 3 | # SAP ANALYTICS CLOUD - CUSTOM WIDGET SAMPLES 4 | 5 | 6 | 9 | 10 | ## Important to Know 11 | this repository is not anymore maintained, please use the new GitHub link to find the same content: https://github.com/SAP-samples/analytics-cloud-datasphere-community-content/tree/main/SAC_Custom_Widgets 12 | 13 | ## License 14 | Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file. 15 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-PackageName = "analytics-cloud-custom-widget" 3 | SPDX-PackageSupplier = "m.ferchichi@sap.com and jie.deng@sap.com" 4 | SPDX-PackageDownloadLocation = "" 5 | SPDX-PackageComment = "The code in this project may include calls to APIs (\"API Calls\") of\n SAP or third-party products or services developed outside of this project\n (\"External Products\").\n \"APIs\" means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project's code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls." 6 | 7 | [[annotations]] 8 | path = "**" 9 | precedence = "aggregate" 10 | SPDX-FileCopyrightText = "2022 SAP SE or an SAP affiliate company and analytics-cloud-custom-widget contributors" 11 | SPDX-License-Identifier = "Apache-2.0" 12 | --------------------------------------------------------------------------------