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 } = require('qix-faker');
const hc = hypercube({
dimensions: [f => f.commerce.product()],
measures: [f => f.commerce.price(100, 5000, 2, '
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.
qixFaker.hypercube({
numRows: 10,
seed: 5,
dimensions: [
{
value: (faker, rowIdx) => faker.date.month(),
},
],
});
qixFaker.listobject(options)
- options
<object>
- dimension
<field>.
- numRows
<number> - Number of rows to generate.
- seed
<number> - Set the same number to generate consistent results.
qixFaker.listobject({
numRows: 10,
seed: 5678,
dimension: f => d.name.firstName(),
});
types
field <function | object>
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.
hypercube({
dimensions: [(faker, idx) => faker.commerce.product()],
measures: [(faker, idx) => faker.finance.amount(100, 3000, 2, '
<object>
Using an object provides more control:
- value:
<function(faker, rowIndex)> - Same function as above.
- maxCardinalRatio
<number> - A value between 0 - 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.
hypercube({
numRows: 100,
dimensions: [
{
value: f => f.address.city(),
maxCardinalRatio: 0.4,
attrDim: [f => f.commerce.color()],
attrExps: [f => f.random.number()]
override: {
qFallbackTitle: 'City',
qLocked: true,
},
},
],
});
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.
hypercube({
numRows: 80,
dimensions: [
{
value: f => f.address.country(),
maxCardinalRatio: 0.1,
},
{
value: f => f.address.city(),
},
],
});
In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.
)],
numRows: 3,
});
const lo = listobject({
dimension: [f => f.commerce.product()],
numRows: 5,
});
API
qixFaker.hypercube(options)
- options __INLINE_CODE_0__
- dimensions __INLINE_CODE_1__ - Dimensions.
- measures __INLINE_CODE_2__ - Measures.
- numRows __INLINE_CODE_3__ - Number of rows to generate.
- seed __INLINE_CODE_4__ - Set the same number to generate consistent results.
__CODE_BLOCK_2__
qixFaker.listobject(options)
- options __INLINE_CODE_5__
- dimension __INLINE_CODE_6__.
- numRows __INLINE_CODE_7__ - Number of rows to generate.
- seed __INLINE_CODE_8__ - Set the same number to generate consistent results.
__CODE_BLOCK_3__
types
field __INLINE_CODE_9__
A __INLINE_CODE_10__ configuration can take on two different shapes:
__INLINE_CODE_11__
A function which is provided the __INLINE_CODE_12__ instance as first parameter, and the __INLINE_CODE_13__ as the second. See the faker api for details on params of each method.
__CODE_BLOCK_4__
__INLINE_CODE_14__
Using an object provides more control:
- value: __INLINE_CODE_15__ - Same function as above.
- maxCardinalRatio __INLINE_CODE_16__ - A value between __INLINE_CODE_17__ to limit the uniqueness of dimension values.
- attrDims __INLINE_CODE_18__ - Attribute dimensions.
- attrExps __INLINE_CODE_19__ - Attribute expression.
- override __INLINE_CODE_20__ - Set custom properties on the field.
__CODE_BLOCK_5__
In the above example, 100 rows of data is generated using the __INLINE_CODE_21__ dataset provided in __INLINE_CODE_22__, 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; __INLINE_CODE_23__ provides a way to do just that.
Assume we want to generate some data containing cities grouped by country, by setting __INLINE_CODE_24__ to a low number we can create such a dataset.
__CODE_BLOCK_6__
In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.
)],
});
__INLINE_CODE_14__
Using an object provides more control:
- value: __INLINE_CODE_15__ - Same function as above.
- maxCardinalRatio __INLINE_CODE_16__ - A value between __INLINE_CODE_17__ to limit the uniqueness of dimension values.
- attrDims __INLINE_CODE_18__ - Attribute dimensions.
- attrExps __INLINE_CODE_19__ - Attribute expression.
- override __INLINE_CODE_20__ - Set custom properties on the field.
In the above example, 100 rows of data is generated using the __INLINE_CODE_21__ dataset provided in __INLINE_CODE_22__, 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; __INLINE_CODE_23__ provides a way to do just that.
Assume we want to generate some data containing cities grouped by country, by setting __INLINE_CODE_24__ to a low number we can create such a dataset.
__CODE_BLOCK_6__In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.
)], numRows: 3, }); const lo = listobject({ dimension: [f => f.commerce.product()], numRows: 5, });API
qixFaker.hypercube(options)
- options __INLINE_CODE_0__
- dimensions __INLINE_CODE_1__ - Dimensions.
- measures __INLINE_CODE_2__ - Measures.
- numRows __INLINE_CODE_3__ - Number of rows to generate.
- seed __INLINE_CODE_4__ - Set the same number to generate consistent results.
qixFaker.listobject(options)
- options __INLINE_CODE_5__
- dimension __INLINE_CODE_6__.
- numRows __INLINE_CODE_7__ - Number of rows to generate.
- seed __INLINE_CODE_8__ - Set the same number to generate consistent results.
types
field __INLINE_CODE_9__
A __INLINE_CODE_10__ configuration can take on two different shapes:
__INLINE_CODE_11__
A function which is provided the __INLINE_CODE_12__ instance as first parameter, and the __INLINE_CODE_13__ as the second. See the faker api for details on params of each method.
__CODE_BLOCK_4____INLINE_CODE_14__
Using an object provides more control:
- value: __INLINE_CODE_15__ - Same function as above.
- maxCardinalRatio __INLINE_CODE_16__ - A value between __INLINE_CODE_17__ to limit the uniqueness of dimension values.
- attrDims __INLINE_CODE_18__ - Attribute dimensions.
- attrExps __INLINE_CODE_19__ - Attribute expression.
- override __INLINE_CODE_20__ - Set custom properties on the field.
In the above example, 100 rows of data is generated using the __INLINE_CODE_21__ dataset provided in __INLINE_CODE_22__, 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; __INLINE_CODE_23__ provides a way to do just that.
Assume we want to generate some data containing cities grouped by country, by setting __INLINE_CODE_24__ to a low number we can create such a dataset.
__CODE_BLOCK_6__In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.