qix-faker
Powered by faker.js
Generate fake Qlik Engine data in the shape of hypercubes and listobjects.
Great for prototyping with picasso.js, nebula.js and any other time when a real Qlik Engine is not available.
Usage
node.js
npm install qix-faker
const hypercube listobject = ; const hc = ; const lo = ;
API
qixFaker.hypercube(options)
- options
<object>
- dimensions
<Array<field>>
- Dimensions. - measures
<Array<field>>
- Measures. - numRows
<number>
- Number of rows to generate. - seed
<number>
- Set the same number to generate consistent results.
- dimensions
qixFaker;
qixFaker.listobject(options)
- options
<object>
- dimension
<field>
. - numRows
<number>
- Number of rows to generate. - seed
<number>
- Set the same number to generate consistent results.
- dimension
qixFaker;
types
<function | object>
field A field
configuration can take on two different shapes:
<function(faker, rowIndex)>
A function which is provided the faker
instance as first parameter, and the rowIndex
as the second. See the faker api for details on params of each method.
;
<object>
Using an object provides more control:
- value:
<function(faker, rowIndex)>
- Same function as above. - maxCardinalRatio
<number>
- A value between0 - 1
to limit the uniqueness of dimension values. - attrDims
<Array<field>>
- Attribute dimensions. - attrExps
<Array<field>
- Attribute expression. - override
<object>
- Set custom properties on the field.
;
In the above example, 100 rows of data is generated using the city
dataset provided in faker
, there is however no guarantee that all 100 rows will be unique.
In some cases though, it might be desirable to limit the uniqueness of the generated values; maxCardinalRatio
provides a way to do just that.
Assume we want to generate some data containing cities grouped by country, by setting maxCardinalRatio
to a low number we can create such a dataset.
;
In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.