PHP code example of soandso / continental-index

1. Go to this page and download the library: Download soandso/continental-index library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soandso / continental-index example snippets






use Soandso\ContinentalIndex\Register;

$report = new Register($inputType, $source, $inputTempUnits, $outputTempUnits, $latitude);

$inputType - Supported types of source data:
Register::FILE
Register::ARRAY
Register::JSON

$source - Input source:
1. File (Show file path)
Source data structure:
Year, space, temperature amplitude value
Example:
2022 78.5

2. array:
[
  Year, temperature amplitude value
]
Example:
[
  [2017, 80.9],
  [2018, 70.3],
  ............
]

3. json:
This format is an array (see above) encoded into a json string

$inputTempUnits - Input temperature amplitude units:
Register::FAHRENHEIT
Register::CELSIUS

$outputTempUnits - Output temperature amplitude units:
Register::FAHRENHEIT
Register::CELSIUS

$latitude - Location latitude



$index->getIndex(string $title, string $format, string $filePath = null);

$title - Type index of continentality
The following methods for calculating the continentality index are supported:

1. Hromov continentality index - Register::HROMOV_INDEX
2. Gorchinsky continentality index - Register::GORCHINSKY_INDEX
3. Conrad continentality index - Register::CONRAD_INDEX
4. Zenker continentality index - Register::ZENKER_INDEX


$format - Output format
Register::FILE
Register::ARRAY
Register::JSON

$filePath - The path to the directory for extracting the results file

 Register::plot($indexAssets)
 Register::plot($indexAssets, $options)

$options = [
/** Show or hide the range selector widget (Only for Dygraph provider) **/
'showRangeSelector'      => null, //true or false
/** Height, in pixels, of the range selector widget (Only for Dygraph provider) **/
'rangeSelectorHeight'    => null, //int
/** Width, in pixels, of the chart **/
'width'                  => null, //int
/** Height, in pixels, of the chart **/
'height'                 => null, //int
'title'                  => 'Continental index',
/** Text to display to the left of the chart's y-axis **/
'ylabel'                 => 'Index', //string
/** Text to display below the chart's x-axis **/
'xlabel'                 => 'Date', //string
];

$index = new Register(Register::FILE, __DIR__ . '/amplitude.txt', Register::FAHRENHEIT, Register::CELSIUS, 45.5);
$indexAssets = $index->getIndex(Register::HROMOV_INDEX, Register::FILE, __DIR__);

Register::plot($indexAssets);

Register::plot($indexAssets, [
        'showRangeSelector' => true,
        'rangeSelectorHeight' => 30,
        'title' => 'Hromov Index',
]);
bash
$ php composer.phar install
bash
$ php composer.phar