public function getSellmeierData() { $sell = new Sellmeier(); $sell->loadMaterialsData(); // Make material selection if it exists if (isset($_GET['selection'])) { // Parse selection $selection = json_decode(urldecode($_GET['selection'])); //print_r($selection); if (!$sell->selectMaterials($selection)) { $errors[] = new Error("Materials do not exist", 1); } // Parse legend $legend = array(); if (isset($_GET['legend']) && is_array($_GET['legend']) && count($_GET['legend']) == count($selection)) { $legend = $_GET['legend']; } else { foreach ($selection as $material => $array) { foreach ($array as $key => $axis) { $legend[] = $material . " (axis " . $axis . ")"; } } } $sell->legend($legend); // Parse title if (isset($_GET['title'])) { $title = $_GET['title']; $sell->title($title); } // Parse domain $xmin = 0.4; $xmax = 1; $step = 0.001; if (isset($_GET['xmin']) && isset($_GET['xmax']) && isset($_GET['step'])) { if (is_numeric($_GET['xmin']) && is_numeric($_GET['xmax']) && is_numeric($_GET['step'])) { $xmin = $_GET['xmin'] + 0; $xmax = $_GET['xmax'] + 0; $step = $_GET['step'] + 0; } else { $errors[] = new Error("Wavelength range must be a number", 2); } } $sell->setX($xmin, $xmax, $step); $sell->setY(); // Output plot data echo $sell->getJson(); } else { // Output materials list echo $sell->getMaterialsJson(); } }