Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Hyper cube layout as input (#16)
Browse files Browse the repository at this point in the history
* Add new tests
Move test with option to option section

* Add section functionality
Update table.md with new option properties

* Add test for script prefix

* Fix test table prefix script

* Add prefix script functionality

* Fix line endings and linting

* Proof of concept

* Fix unique values dual map table
Fix timestamp, date, time field types with format
Fix validation of hyper cube layout

* Add interval field type
Refactor HyperCube
Add hyper-cube-utils

* Update documentation
Fix bug duals after refactoring
Add new test getItems()

* Refactor hyper-cube.js
Add more tests (hyper-cube)

* Fix #9
Refactor hyper-cube-utils and hyper-cube
Add tests for hyper cube
Add tests for halyard addHyperCube

* Update with changes suggested by StefanEnberg

* Improve validate HyperCubeLayout
  • Loading branch information
KFredberg authored and StefanEnberg committed Aug 8, 2017
1 parent 041a109 commit 48704f1
Show file tree
Hide file tree
Showing 17 changed files with 2,333 additions and 128 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ halyard.addTable('c:\\data\\file.csv', 'TableName');

`addTable` returns a Halyard.Table instance

### `addHyperCube(hyperCube)`

Adds a hyper cube to the data model representation. More info about [Halyard.HyperCube](docs/hyper-cube.md).

The `addHyperCube` method accepts an explicit hyper cube definition:

```javascript
let hyperCube = new Halyard.HyperCube(qHyperCube);
halyard.addHyperCube(hyperCube);
```
Example [qHyperCube](examples/data/hyper-cube.json)

`addHyperCube` returns a Halyard.HyperCube instance

### `addHyperCube(hyperCubeLayout[, hyperCubeOptions])`

You can also add a hyper cube by providing the hyper cube definition:

```javascript
halyard.addHyperCube(qHyperCube, 'HyperCubeName');
```

`addHyperCube` returns a Halyard.HyperCube instance
An example of a how to use this method [hyper-cube.js in examples](examples/hyper-cube.js)

### `addItem(item)`

Adds any object that responds to `getScript()`. An example of a how to use this method to extend with custom functionality [extending-functionality.js in examples](examples/extending-functionality.js)
Expand Down
33 changes: 33 additions & 0 deletions docs/hyper-cube.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### `Halyard.HyperCube`

### `new Halyard.HyperCube( hyperCubeLayout[, options] )`
A hyper cube is the representation of a hyper cube layout made up by a table/tables. If the hyper cube layout contains dual fields each dual field will have a map table associated.

```javascript
let hyperCube = new Halyard.HyperCube(qHyperCube, "Car Makers");
```

The first parameter is the hyper cube layout, and the second parameter is the options JSON or the hyper cube name.

#### hyper cube layout
The hyper cube layout needs to have data in qDataPages. Only hyper cubes with qMode equals S for DATA_MODE_STRAIGHT is supported. Example [qHyperCube](../examples/data/hyper-cube.json)


### options
Optional parameter. Can be either the hyper cube name as a String, or the following structure:

| Property | Type | Description |
|----------|--------|-------------|
| `name` | String | The name of the table |
| `section` | String | The name of the script section. If left empty the script is appended to the previous script section |

An example of using options:

```javascript
let hyperCube = new Halyard.HyperCube(qHyperCube, { name: 'Data', section: 'Data (HyperCube)' });
```

### `getItems()`

Returns the items (Halyard.Table) needed to load the hyper cube layout and the options provided.

2 changes: 2 additions & 0 deletions docs/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ Optional parameter. Can be either the table name as a String, or the following s
| Property | Type | Description |
|----------|--------|-------------|
| `name` | String | The name of the table |
| `prefix` | String | The script prefix function to be used before the load statement |
| `fields` | Array of Fields | See Field definition below. If no fields are specified then all will be loaded from the source's first table or if specified from srcTable. |
| `delimiter` | String | The character that delimits a CSV file |
| `headerRowNr` | Number | The location of the header row |
| `srcTable` | String | The name of the table in the source file. IE: this could be the sheet name in XLSX. |
| `section` | String | The name of the script section. If left empty the script is appended to the previous script section |


#### Field definition
Expand Down
61 changes: 31 additions & 30 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# Prerequisites

Needs a QIX Engine installed. The configurations in this example is for a Qlik Sense Desktop installation but can be changed in the [enigma-config.js](enigma-config.js) file to work with other setups.
Requires NodeJS to be installed.

# Installation

In the root folder, type the following:

- npm install
- npm run build

Go into the examples folder and type the following in the console:

- npm install

# Run

Make sure that a QIX engine is started (the examples are pre-configured for a Qlik Sense Desktop to be started)

- node inline-data.js

| Example | |
| ------- | ---|
| [inline-data.js](inline-data.js) | Loads a local JSON file into QIX engine in a new doc using inline table |
| [local-data.js](local-data.js) | Load a local CSV file into QIX engine in a new doc using folder connection |
| [web-data.js](web-data.js) | Load a table from a web site into QIX engine in a new doc using a webfile connection |
| [session-app.js](session-app.js) | Load a table from a web site into QIX engine in a new doc using a webfile connection |
| [field-list-with-formatting.js](field-list-with-formatting.js) | Load a local CSV file with a defined field list using `type`, `inputFormat`, `displayFormat` and `expr` into QIX engine in a new doc using a folder connection |
| [extending-functionality.js](extending-functionality.js) | How to extend the functionality using a custom item that generates script into QIX engine |
# Prerequisites

Needs a QIX Engine installed. The configurations in this example is for a Qlik Sense Desktop installation but can be changed in the [enigma-config.js](enigma-config.js) file to work with other setups.
Requires NodeJS to be installed.

# Installation

In the root folder, type the following:

- npm install
- npm run build

Go into the examples folder and type the following in the console:

- npm install

# Run

Make sure that a QIX engine is started (the examples are pre-configured for a Qlik Sense Desktop to be started)

- node inline-data.js

| Example | |
| ------- | ---|
| [inline-data.js](inline-data.js) | Loads a local JSON file into QIX engine in a new doc using inline table |
| [local-data.js](local-data.js) | Load a local CSV file into QIX engine in a new doc using folder connection |
| [web-data.js](web-data.js) | Load a table from a web site into QIX engine in a new doc using a webfile connection |
| [hyper-cube.js](hyper-cube.js) | Load a hyper cube layout from a json file into QIX engine in a new doc |
| [session-app.js](session-app.js) | Load a table from a web site into QIX engine in a new doc using a webfile connection |
| [field-list-with-formatting.js](field-list-with-formatting.js) | Load a local CSV file with a defined field list using `type`, `inputFormat`, `displayFormat` and `expr` into QIX engine in a new doc using a folder connection |
| [extending-functionality.js](extending-functionality.js) | How to extend the functionality using a custom item that generates script into QIX engine |
Loading

0 comments on commit 48704f1

Please sign in to comment.