1.0.1 • Published 6 years ago

fancy-data v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

FancyData

FancyData - JavaScript Mockup Data Generation Library

Install

npm install fancy-data

Include

<script src="/dist/bundle.min.js"></script>

CDN

<script src="https://cdn.fancygrid.com/fancydata.min.js"></script>

Sample

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);
  }
});

Core Properties

NameTypeDescription
columnsArrayList with columns config
indexesArrayData indexes, if not provided than it data could contain more options than columns
rowsNumberNumber of data rows

Column types

age

Age range value from min and max values.
By default min is 0 and max is 100.

Properties
NameType
typeString
indexString
maxNumber
minNumber
Sample
{
  type: 'age',
  min: 20,
  max: 45,
  index: 'age'
}

boolean

Boolean value true or false.

Properties
NameType
typeString
indexString
Sample
{
  type: 'boolean',
  index: 'married'
}

company

Random company from small list.

Properties
NameType
typeString
indexString
Sample
{
  type: 'company',
  index: 'company'
}

country

Random country from almost all countries list.

Properties
NameType
typeString
indexString
Sample
{
  type: 'country',
  index: 'country'
}

country-rich

Random rich country.

Properties
NameType
typeString
indexString
Sample
{
  type: 'country-rich',
  index: 'country'
}

date

Date value in format 'm.d.Y' by default between min 1970.1.1 and current date.

Properties
NameType
typeString
indexString
formatString
minNumber
maxNumber
Sample
{
  type: 'date',
  index: 'birthday',
  format: 'm/d/Y',
  min: new Date(1980, 1, 7)
}

email

Person email on base of 'name', 'surname', 'site'. 'site' is column property but name and surname must be extra columns.

Properties
NameType
typeString
indexString
tplString
siteNumber
maxNumber
Sample
{
  type: 'email',
  index: 'email',
  site: 'google.com'
}

float

Float number value with presition between range.

Properties
NameType
typeString
indexString
presitionNumber
minNumber
maxNumber
Sample
{
  type: 'float',
  index: 'bank_balance',
  presition: 2,
  min: 0,
  max: 150000
}

fortune100

Company from fortune 100 list.

Properties
NameType
typeString
indexString
Sample
{
  type: 'fortune100',
  index: 'company'
}

fortune500

Company from fortune 500 list.

Properties
NameType
typeString
indexString
Sample
{
  type: 'fortune500',
  index: 'company'
}

gender

Person gender, possible values: 'male'|'female'.
Requires extra column name.

Properties
NameType
typeString
indexString
Sample
{
  type: 'fortune500',
  index: 'company'
}

id

Incremental id value start from 1 by default.

Properties
NameType
typeString
indexString
minNumber
Sample
{
  type: 'fortune500',
  index: 'company'
}

int

Integer number value between range.

Properties
NameType
typeString
indexString
minNumber
maxNumber
Sample
{
  type: 'int',
  index: 'value',
  min: 1000,
  max: 100000
}

it-level

Proffesional person level.

Properties
NameType
typeString
indexString
Sample
{
  type: 'it-level',
  index: 'level'
}

it-position

Person position in tech sphere.

Properties
NameType
typeString
indexString
Sample
{
  type: 'it-level',
  index: 'level'
}

name

Person name.

Properties
NameType
typeString
indexString
Sample
{
  type: 'name',
  index: 'name'
}

salary-year

Person salary per year in range

Properties
NameType
typeString
indexString
minNumber
maxNumber
Sample
{
  type: 'salary-year',
  index: 'salary'
}

surname

Person surname

Properties
NameType
typeString
indexString
Sample
{
  type: 'surname',
  index: 'surname'
}

usa-state

Random USA state

Properties
NameType
typeString
indexString
Sample
{
  type: 'usa-state',
  index: 'state'
}