Newer
Older
HoteleriaAdmin / src / app / charts / ngx-charts / chartData.ts
James Cuadrado on 26 May 2021 9 KB init
export const single = [
  {
    name: 'Germany',
    value: 40
  },
  {
    name: 'USA',
    value: 49
  },
  {
    name: 'France',
    value: 36
  },
  {
    name: 'United Kingdom',
    value: 36
  },
  {
    name: 'Spain',
    value: 33
  },
  {
    name: 'Italy',
    value: 35
  }
];

export const multi = [
  {
    name: 'Germany',
    series: [
      {
        name: '2010',
        value: 40
      },
      {
        name: '2000',
        value: 36
      },
      {
        name: '1990',
        value: 31
      }
    ]
  },
  {
    name: 'USA',
    series: [
      {
        name: '2010',
        value: 49
      },
      {
        name: '2000',
        value: 45
      },
      {
        name: '1990',
        value: 37
      }
    ]
  },
  {
    name: 'France',
    series: [
      {
        name: '2010',
        value: 36
      },
      {
        name: '2000',
        value: 34
      },
      {
        name: '1990',
        value: 29
      }
    ]
  },
  {
    name: 'United Kingdom',
    series: [
      {
        name: '2010',
        value: 36
      },
      {
        name: '2000',
        value: 32
      },
      {
        name: '1990',
        value: 26
      }
    ]
  }
];

export const bubble = [
  {
    name: 'Germany',
    series: [
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 80.3,
        r: 80.4
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 80.3,
        r: 78
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 75.4,
        r: 79
      }
    ]
  },
  {
    name: 'USA',
    series: [
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 78.8,
        r: 310
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 76.9,
        r: 283
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 75.4,
        r: 253
      }
    ]
  },
  {
    name: 'France',
    series: [
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 81.4,
        r: 63
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 79.1,
        r: 59.4
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 77.2,
        r: 56.9
      }
    ]
  },
  {
    name: 'United Kingdom',
    series: [
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 80.2,
        r: 62.7
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 77.8,
        r: 58.9
      },
      {
        name: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        x: new Date(Math.floor(1473700105009 + Math.random() * 1000000000)),
        y: 75.7,
        r: 57.1
      }
    ]
  }
];

export const countries = [
  'Abkhazia',
  'Afghanistan',
  'Akrotiri and Dhekelia',
  'Aland',
  'Albania',
  'Algeria',
  'American Samoa',
  'Andorra',
  'Angola',
  'Anguilla',
  'Antigua and Barbuda',
  'Argentina',
  'Armenia',
  'Aruba',
  'Ascension Island',
  'Australia',
  'Austria',
  'Azerbaijan',
  'Bahamas, The',
  'Bahrain',
  'Bangladesh',
  'Barbados',
  'Belarus',
  'Belgium',
  'Belize',
  'Benin',
  'Bermuda',
  'Bhutan',
  'Bolivia',
  'Bosnia and Herzegovina',
  'Botswana',
  'Brazil',
  'Brunei',
  'Bulgaria',
  'Burkina Faso',
  'Burundi',
  'Cambodia',
  'Cameroon',
  'Canada',
  'Cape Verde',
  'Cayman Islands',
  'Central Africa Republic',
  'Chad',
  'Chile',
  'China',
  'Christmas Island',
  'Cocos (Keeling) Islands',
  'Colombia',
  'Comoros',
  'Congo',
  'Cook Islands',
  'Costa Rica',
  'Cote dlvoire',
  'Croatia',
  'Cuba',
  'Cyprus',
  'Czech Republic',
  'Denmark',
  'Djibouti',
  'Dominica',
  'Dominican Republic',
  'East Timor Ecuador',
  'Egypt',
  'El Salvador',
  'Equatorial Guinea',
  'Eritrea',
  'Estonia',
  'Ethiopia',
  'Falkland Islands',
  'Faroe Islands',
  'Fiji',
  'Finland',
  'France',
  'French Polynesia',
  'Gabon',
  'Cambia, The',
  'Georgia',
  'Germany',
  'Ghana',
  'Gibraltar',
  'Greece',
  'Greenland',
  'Grenada',
  'Guam',
  'Guatemala',
  'Guemsey',
  'Guinea',
  'Guinea-Bissau',
  'Guyana',
  'Haiti',
  'Honduras',
  'Hong Kong',
  'Hungary',
  'Iceland',
  'India',
  'Indonesia',
  'Iran',
  'Iraq',
  'Ireland',
  'Isle of Man',
  'Israel',
  'Italy',
  'Jamaica',
  'Japan',
  'Jersey',
  'Jordan',
  'Kazakhstan',
  'Kenya',
  'Kiribati',
  'Korea, N',
  'Korea, S',
  'Kosovo',
  'Kuwait',
  'Kyrgyzstan',
  'Laos',
  'Latvia',
  'Lebanon',
  'Lesotho',
  'Liberia',
  'Libya',
  'Liechtenstein',
  'Lithuania',
  'Luxembourg',
  'Macao',
  'Macedonia',
  'Madagascar',
  'Malawi',
  'Malaysia',
  'Maldives',
  'Mali',
  'Malta',
  'Marshall Islands',
  'Mauritania',
  'Mauritius',
  'Mayotte',
  'Mexico',
  'Micronesia',
  'Moldova',
  'Monaco',
  'Mongolia',
  'Montenegro',
  'Montserrat',
  'Morocco',
  'Mozambique',
  'Myanmar',
  'Nagorno-Karabakh',
  'Namibia',
  'Nauru',
  'Nepal',
  'Netherlands',
  'Netherlands Antilles',
  'New Caledonia',
  'New Zealand',
  'Nicaragua',
  'Niger',
  'Nigeria',
  'Niue',
  'Norfolk Island',
  'Northern Cyprus',
  'Northern Mariana Islands',
  'Norway',
  'Oman',
  'Pakistan',
  'Palau',
  'Palestine',
  'Panama',
  'Papua New Guinea',
  'Paraguay',
  'Peru',
  'Philippines',
  'Pitcaim Islands',
  'Poland',
  'Portugal',
  'Puerto Rico',
  'Qatar',
  'Romania',
  'Russia',
  'Rwanda',
  'Sahrawi Arab Democratic Republic',
  'Saint-Barthelemy',
  'Saint Helena',
  'Saint Kitts and Nevis',
  'Saint Lucia',
  'Saint Martin',
  'Saint Pierre and Miquelon',
  'Saint Vincent and Grenadines',
  'Samos',
  'San Marino',
  'Sao Tome and Principe',
  'Saudi Arabia',
  'Senegal',
  'Serbia',
  'Seychelles',
  'Sierra Leone',
  'Singapore',
  'Slovakia',
  'Slovenia',
  'Solomon Islands',
  'Somalia',
  'Somaliland',
  'South Africa',
  'South Ossetia',
  'Spain',
  'Sri Lanka',
  'Sudan',
  'Suriname',
  'Svalbard',
  'Swaziland',
  'Sweden',
  'Switzerland',
  'Syria',
  'Tajikistan',
  'Tanzania',
  'Thailand',
  'Togo',
  'Tokelau',
  'Tonga',
  'Transnistria',
  'Trinidad and Tobago',
  'Tristan da Cunha',
  'Tunisia',
  'Turkey',
  'Turkmenistan',
  'Turks and Caicos Islands',
  'Tuvalu',
  'Uganda',
  'Ukraine',
  'United Arab Emirates',
  'United Kingdom',
  'United States',
  'Uruguay',
  'Uzbekistan',
  'Vanuatu',
  'Vatican City',
  'Venezuela',
  'Vietnam',
  'Virgin Islands, British',
  'Virgin Islands, U.S.',
  'Wallis and Futuna',
  'Yemen',
  'Zambia',
  'Zimbabwe'
];

export function generateGraph(nodeCount: number) {
  const nodes = [];
  const links = [];
  for (let i = 0; i < nodeCount; i++) {
    const country = countries[Math.floor(Math.random() * countries.length)];
    nodes.push({
      value: country
    });
    for (let j = 0; j < nodes.length - 1; j++) {
      if (Math.random() < 0.03) {
        links.push({
          source: country,
          target: nodes[j].value
        });
      }
    }
  }
  return { links, nodes };
}

export function generateData(
  seriesLength: number,
  includeMinMaxRange: boolean
): any[] {
  const results = [];

  const domain: Date[] = []; // array of time stamps in milliseconds

  for (let j = 0; j < 8; j++) {
    // random dates between Sep 12, 2016 and Sep 24, 2016
    domain.push(
      new Date(Math.floor(1473700105009 + Math.random() * 1000000000))
    );
  }

  for (let i = 0; i < seriesLength; i++) {
    const country = countries[Math.floor(Math.random() * countries.length)];
    const series = {
      name: country,
      series: []
    };

    for (let j = 0; j < domain.length; j++) {
      const value = Math.floor(2 + Math.random() * 5);
      // let timestamp = Math.floor(1473700105009 + Math.random() * 1000000000);
      const timestamp = domain[j];
      if (includeMinMaxRange) {
        const errorMargin = 0.02 + Math.random() * 0.08;

        series.series.push({
          value,
          name: timestamp,
          min: Math.floor(value * (1 - errorMargin)),
          max: Math.ceil(value * (1 + errorMargin))
        });
      } else {
        series.series.push({
          value,
          name: timestamp
        });
      }
    }

    results.push(series);
  }
  return results;
}