FancyData - JavaScript Mockup Data Generation Library
npm install fancy-data
<script src="/dist/bundle.min.js"></script>
<script src="https://cdn.fancygrid.com/fancydata.min.js"></script>
new FancyData({
rows: 1000000,
indexes: ['id', 'name', 'surname', 'country', 'position', 'email', 'age'],
columns: [{
type: 'id',
index: 'id'
},{
type: 'name',
index: 'name'
},{
type: 'surname',
index: 'surname'
},{
type: 'country-rich',
index: 'country'
},{
type: 'it-position',
index: 'position'
},{
type: 'email',
index: 'email',
site: 'google.com'
},{
type: 'age',
min: 20,
max: 45,
index: 'age'
}]
}).getData({
on1000: function(generated, percents, total){
console.log(generated, percents, total)
},
onFinished: function(data){
console.log('onFinished', data);
}
});
Name | Type | Description |
---|---|---|
columns |
Array | List with columns config |
indexes |
Array | Data indexes, if not provided than it data could contain more options than columns |
rows |
Number | Number of data rows |
Age range value from min and max values.
By default min is 0 and max is 100.
Name | Type |
---|---|
type |
String |
index |
String |
max |
Number |
min |
Number |
{
type: 'age',
min: 20,
max: 45,
index: 'age'
}
Boolean value true or false.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'boolean',
index: 'married'
}
Random company from small list.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'company',
index: 'company'
}
Random country from almost all countries list.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'country',
index: 'country'
}
Random rich country.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'country-rich',
index: 'country'
}
Date value in format 'm.d.Y' by default between min 1970.1.1 and current date.
Name | Type |
---|---|
type |
String |
index |
String |
format |
String |
min |
Number |
max |
Number |
{
type: 'date',
index: 'birthday',
format: 'm/d/Y',
min: new Date(1980, 1, 7)
}
Person email on base of 'name', 'surname', 'site'. 'site' is column property but name and surname must be extra columns.
Name | Type |
---|---|
type |
String |
index |
String |
tpl |
String |
site |
Number |
max |
Number |
{
type: 'email',
index: 'email',
site: 'google.com'
}
Float number value with presition between range.
Name | Type |
---|---|
type |
String |
index |
String |
presition |
Number |
min |
Number |
max |
Number |
{
type: 'float',
index: 'bank_balance',
presition: 2,
min: 0,
max: 150000
}
Company from fortune 100 list.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'fortune100',
index: 'company'
}
Company from fortune 500 list.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'fortune500',
index: 'company'
}
Person gender, possible values: 'male'|'female'.
Requires extra column name.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'fortune500',
index: 'company'
}
Incremental id value start from 1 by default.
Name | Type |
---|---|
type |
String |
index |
String |
min |
Number |
{
type: 'fortune500',
index: 'company'
}
Integer number value between range.
Name | Type |
---|---|
type |
String |
index |
String |
min |
Number |
max |
Number |
{
type: 'int',
index: 'value',
min: 1000,
max: 100000
}
Proffesional person level.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'it-level',
index: 'level'
}
Person position in tech sphere.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'it-level',
index: 'level'
}
Person name.
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'name',
index: 'name'
}
Person salary per year in range
Name | Type |
---|---|
type |
String |
index |
String |
min |
Number |
max |
Number |
{
type: 'salary-year',
index: 'salary'
}
Person surname
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'surname',
index: 'surname'
}
Random USA state
Name | Type |
---|---|
type |
String |
index |
String |
{
type: 'usa-state',
index: 'state'
}