/**
класс objAnalys.js
анализ точек  и  графики
==============================================================================================
дополнительные классы:
objD3 - вспомогательные классы с функциями рисования в рамках d3.js
objIsolines - обсчет точек и создание изолини
==============================================================================================
функции класса: 
build() - сборка всех функций для построения  
toolbar() - интерфейс панели управления
generatepoints() - создание Axis, генерация точек, гиперболы и текста
get_arr_curve(арг) формирование массива арг:(минимальное, максимальное, шаг, номер колонки массива)
generate_graph() - рисование графиков
==============================================================================================
(c) Mychko Eduard, 2015, Moscow, Russia, eduard.mychko@gmail.com
==============================================================================================
*/

var objAnalys = {
	/*--------------------------------------------------------------переменные--------------------------------------------------------------*/
	'canvas' : '#content-analyses-canvas', /* DIV канва для SVG */
	/* параметры для графиков, num_col - номер ключа в массиве dataset */
	'graphparam' : {
				'W' : {'min' : 0.5,'max' : 5.5,'step' :  0.2,'num_col' : 1},
				'D' : {'min' : 0,'max' :   0.7,'step' : 0.05,'num_col' : 2},
				'S' : {'min' : 0.3,'max' : 3.5,'step' : 0.05,'num_col' : 3},
			},
	//'dataset' : [['Prolec. librovitchi','1.75','0.49'],['Dombaroc. chancharensis','1.37','0.3'],['Dombaroc. catillus','1.23','0.37'],['Epican. aktubensis','2.21','0.3'],['Megapr. sakmarensis','1.58','0.25'],['Uralopr. mirus','1.56','0.15'],['Irin. arcuatum','2.4','0.05'],['Sudet. grande','1.66','0.05'],['Nomism. vittigerum','1.15','0.35'],['Cavil. tenuicula','1.34','0.38'],['Girtyoc. latum','2.14','0.09'],['Girtyoc. glabrum','1.22','0.08'],['Girtyoc. mod. modestum','1.37','0.05'],['Girtyoc. mod. medium','1.71','0.05'],['Girtyoc. mod. finale','1.71','0.11'],['Eumorph. sagittarium','1.22','0.09'],['Eumorph. artumbilicatum','1.85','0.1'],['Eumorph. weetense','1.56','0.08'],['Eumorph. transuralense','1.87','0.2'],['Eumorph. bisulcatum','1.47','0.08'],['Eumorph. paucinodum','2.23','0.17'],['Eumorph. tumulosum','3.33','0.26'],['Tumul. eurinus','3.36','0.22'],['Triz. medioximum','2.9','0.04'],['Glyphiol. latisellatus','2.14','0.07'],['Paradimorph. orientale','1.94','0.03'],['Paradimorph. strictum','2.11','0.03'],['Kazakh. hawkinsi','1.62','0.01'],['Eogoniolob. discoides','1.34','0.11'],['Arc. burmai','1.44','0.04'],['Neogoniat. ruginosus','1.62','0.08'],['Neogoniat. mill. milleri','1.96','0.07'],['Neogoniat. mill. latus','2.02','0.09'],['Hypergoniat. tenuiliratus','2.07','0.11'],['Hypergoniat. exiguus','1.91','0.13'],['Platygoniat. omniliratus','1.36','0.17'],['Platygoniat. molaris','1.12','0.14'],['Platygoniat. nudus','1.27','0.17'],['Platygoniat. superior','1.41','0.09'],['Delep. bressoni','1.97','0.09'],['Dombarit. falcatiodes','2.13','0.12'],['Dombarit. carinatus','1.89','0.11'],['Dombarit. tectus','1.95','0.08'],['Dombarit. paratectus','2.15','0.07'],['Dombarit. parafalcatiodes','1.7','0.16'],['Dombarit. liratus','1.86','0.09'],['Dombarit. liratostriatus','1.66','0.03'],['Dombarit. linteroides','2.2','0.08'],['Dombarit. semiliratus','1.48','0.07'],['Pericl. uralicus','2.21','0.07'],['Pericl. atticus','2.21','0.09'],['Proshum. principalis','2','0.04'],['Proshum. delepinei','2.05','0.06'],['Pachylyr. cloudi','3.63','0.54'],['Pachylyr. consequens','2.7','0.39'],['Pachylyr. angustum','2.04','0.35'],['Pachylyr. constrictum','3.22','0.48'],['Dombarigl. indivisia','4.64','0.49'],['Dombarigl. miranda','3.55','0.5'],['Alaoc. bajtalense','3.33','0.4'],['Alaoc. parvum','3.05','0.41'],['Craven. originale','4.04','0.43'],['Craven. lineolatum','2.9','0.22'],['Craven. crassum','3.72','0.36'],['Craven. shimanskyi','3.75','0.23'],['Craven. leionoides','2.77','0.37'],['Craven. insolitum','2.9','0.18'],['Collect. dombarense','3.83','0.36'],['Tympan. rugatum','3.16','0.38'],['Tympan. porrectum','3','0.32'],['Tympan. trisulcatum','3.1','0.42'],['Kardail. primus','2.53','0.3'],['Lyrogoniat. mediator','2.9','0.47'],['Lyrogoniat. mutabilis','2.42','0.33'],['Lyrogoniat. tener','2.24','0.35'],['Caenolyr. subgloboides','3.11','0.24'],['Quasicrav. consuetum','2.24','0.31'],['Quasicraven. costatum','1.86','0.3'],['Quasicraven. infans ','1.45','0.14'],['Veranc. admirabile','2.57','0.23'],['Veranc. tabidum','2.22','0.31'],['Veranc. ciceroides','3.36','0.25'],['Nucul. kazakhstanicum','2.06','0.18'],['Glaphyr. embolicus','3.96','0.38'],['Glaphyr. latus','3.78','0.27'],['Glaphyr. uralensis','2.64','0.38'],['Glaph. solidus','3.84','0.44'],['Pseudoglaphyrites sholakensis','2.63','0.3'],['Syngastr. laxumbilicale','4.25','0.36'],['Syngastr. globosum','4.38','0.36'],['Syngastr. aktubense','3.7','0.3'],['Richard. girtyanus','2.51','0.28'],['Stenoglaphyr. miseri','2.56','0.15'],['Stenoglaphyr. involutus ','2.51','0.1'],['Stenoglaphyr. secretus','1.88','0.16'],['Stenoglaphyr. incisoides','2.57','0.16'],['Zephyr. kiaense','1.69','0.08'],['Euroc. ellipsoidale','2.11','0.11'],['Neoglyphioc. baccans','2.27','0.33'],['Neoglyphioc. caneyanum','1.78','0.14'],['Neoglyphioc. sinuosum','2.01','0.08'],['Neoglyphioc. gradatum','1.43','0.24'],['Neoglyphioc. dignitosum','1.34','0.21'],['Lytheoc. nitidum','1.4','0.23'],['Lytheoc. subcrassulum','1.75','0.19'],['Lusitanit. subcirculatum','1.49','0.18'],['Lusitanit. concavus','1.18','0.1'],['Lusitanit. zuosfanensis','1.35','0.09'],['Lusitanit. multicavus','1.61','0.14'],['Miril. uberta','1.39','0.25'],['Miril. micula','2.04','0.24'],['Fergan. elegans','1.22','0.21'],['Fergan. gracile','1.05','0.24'],['Numm. limbatum','0.85','0.23'],['Ophilyr. tersum','1.84','0.58'],['Rhymmoc. vermiculatum','2.22','0.48'],['Rhymmoc. perlatum','4.18','0.53'],['Rhymmoc. gracilentum','1.31','0.54'],['Fayett. occidentalis','2.7','0.45'],['Fayett. orientalis','2.53','0.42'],['Cravenocerat. hudsoni','2.6','0.15'],['Stenopr. uralensis','1.3','0.13'],['Glyphiol. sholakensis','1.68','0.04'],['Glyphiol. reliquus','2.17','0.01'],['Huds. proteum','1.59','0.21'],['Basch. planus','0.79','0.13'],['Basch. granosus','1.36','0.13'],['Proshum. delepinei','2.32','0.1'],['Proshum. karpinskii','2.3','0.11'],['Aenig. rhipaeum rhipaeum','2.4','0.26'],['Chum. primus','1.67','0.24'],['Chum. alter','2.07','0.26'],['Glaph. uralensis','3.26','0.44'],['Glaph. solidus','3.14','0.31'],['Glaph. sultanaevi','3.33','0.21'],['Glaph. fornicatus','3.67','0.34'],['Syngastr. supinum','4.23','0.41'],['Stenoglaph. superincinus','2.88','0.18'],['Stenoglaph. miserabilis','2.88','0.15'],['Stenoglaph. involutoides','2.77','0.13'],['Stenoglaph. sakmarensis','1.98','0.11'],['Phys. charis','2.53','0.07'],['Subit. sholakense','1.54','0.14'],['Schart. chumazensis','1.92','0.07'],['Schart. barbotanus','2.73','0.05'],['Paraschart. repens','2.14','0.07'],['Ram. corpulentus','2.27','0.14'],['Ram. ramorus','2.1','0.09'],['Ram. subtilis','1.98','0.09'],['Ram. rectus','2.51','0.13'],['Ram. exrectus','2.61','0.09'],['Ram. brevisellatus','1.71','0.07'],['Ram. magnus','1.67','0.09'],['Ram. schartymensis','2.79','0.16'],['Isoh. praematutrum','1.6','0.11'],['Isoh. inostranzewi','1.97','0.12'],['Isoh. modestus','2.35','0.11'],['Vall. schmidti','2.16','0.08'],['Hom. cor. coronatum','1.92','0.16'],['Hom. cor. nudum','1.37','0.16'],['Hom. alveatum','3.45','0.35'],['Hom. subalveatum','2.98','0.28'],['Hom. haug. haugi','3.48','0.36'],['Hom. haug. astrictum','3.11','0.31'],['Hom. schartymense','2.94','0.18'],['Bashk. salavati','1.85','0.1'],['Bashk. kugarchense','3.55','0.25'],['Bashk. artum','1.53','0.1'],['Umbert. uskalykense','3.36','0.38'],['Umbert. karsaklense','3.12','0.24'],['Umbert. kuruilcum','3.12','0.35'],['Fall. portentosus','1.79','0.14'],['Bogd. bifurcum','2.54','0.2'],['Parahom. asperum','3.08','0.19'],['Dec. crassicostatus','1.98','0.25'],['Dec. tenuicostatus','1.29','0.19'],['Brev. inops','1.73','0.43'],['Brev. densus','2.35','0.34'],['Suren. krestovnikovi','1.66','0.22'],['Suren. laxilectus','2.06','0.35'],['Suren. artilectus','2.15','0.33'],['Suren. crenulatus','2.27','0.28'],['Suren. vicinus','2.6','0.37'],['Vern. verneuili','1.86','0.13'],['Vern. keyserlingi','1.83','0.19'],['Vern. progressus','2.11','0.13'],['Vern. murchisoni','2.87','0.27'],['Marian. marianum','3.43','0.29'],['Phillip. alpharhipaeum','1.73','0.24'],['Phillip. betarhipaeum','1.73','0.23'],['Phillip. gammarhipaeum','1.95','0.2'],['Phillip. remissum','2.48','0.37'],['Phillip. separatum','2.34','0.28'],['Phillip. gradile','1.91','0.25'],['Phillip. carinatum','1.67','0.15'],['Phillip. lingulatum','2.14','0.29'],['Alur. costatus','2.55','0.55'],['Alur. postcostatus','2.46','0.48'],['Alur. ventriplanus','1.65','0.42'],['Alur. subcarinatus','1.7','0.42'],['Tect. hodsoni','2.39','0.22'],['Tect. confinis','3.21','0.38'],['Tect. juvenilatus','3.9','0.34'],['Tect. malus','2.16','0.31'],['Tect. laxus','1.7','0.27'],['Tect. posterus','2.05','0.28'],['Ret. ortivus','2.8','0.36'],['Ret. obscurus','2.41','0.25'],['Ret. extremus','4.62','0.42'],['Reticul. surenense','2.11','0.17'],['Reticul. devium','2.69','0.28'],['Reticul. orientale','2.24','0.17'],['Reticul. recticulatum','2.08','0.14'],['Reticul. excultum','2.5','0.13'],['Reticul. instatum','1.39','0.13'],['Bilin. metabilinguis','2.24','0.19'],['Bilin. superbilinguis','1.75','0.16'],['Monit. karpinskii','3.39','0.47'],['Canc. elegans','2.79','0.48'],['Canc. rurae','2.66','0.4'],['Homocer. librovitchi','2.02','0.08'],['Metapr. cuneilobatus','1.5','0.14'],['Udd. convexus','0.77','0.17'],['Agath. uralicum','2.47','0.06'],['Gleb. mirandum','3.07','0.06'],['Schist. suburalense','2.18','0.19'],['Eoas. kajraklense','3.95','0.59'],['Glaph. sakmarensis','3.03','0.33'],['Parashum. eurinus','2.4','0.29'],['Subkarg. neoparkeri','2.75','0.29'],['Boes. primorus','1.73','0.26'],['Neopr. prior','1.32','0.14'],['Neopr. carboniferus','1.42','0.08'],['Proudd. terminalis','1.26','0.06'],['Daix. meglitzky','0.91','0.05'],['Daix. antipovi','1.12','0.04'],['Udd. sakmarensis','1.18','0.21'],['Artin. irinae','0.75','0.06'],['Neoagan. rectilobatus','1.78','0.05'],['Agath. uralicum','2.48','0.02'],['Arist. chkalovi','1.26','0.06'],['Arist. appressum','1.86','0.05'],['Proth. inflatum','2.51','0.04'],['Proth. jaikense','1.57','0.04'],['Proth. bashkirikum ','3.09','0.03'],['Pin. daixense','2.21','0.05'],['Paraschist. optatum','3.52','0.41'],['Schist. uralense','2.73','0.19'],['Eoas. concinnus','4.69','0.63'],['Eoas. postconcinnus','4.1','0.49'],['Eoas. vodorezovi','3.93','0.4'],['Eoas. eximus','3.95','0.5'],['Eoas. bashlirensis','2.97','0.44'],['Som. glomerosus','3.86','0.29'],['Som. sholakensis','5.13','0.48'],['Som. dolium','4.28','0.28'],['Som. ikensis','4.98','0.42'],['Glaph. sakmarensis','3.03','0.33'],['Glaph. lineatus','2.91','0.29'],['Glaph. angulatus','3.58','0.42'],['Glaph. submodestus','2.86','0.25'],['Glaph. striatus','3.37','0.24'],['Glaph. multicavus','2.95','0.34'],['Glaph. rhymnus','2.64','0.28'],['Glaph. pararhymnus','2.72','0.37'],['Glaph. aktubensis','2.62','0.29'],['Shum. confessus','2.64','0.22'],['Shum. librovitchi','3.66','0.45'],['Shum. aktubensis','2.66','0.25'],['Marath. uralensis','2.33','0.12'],['Vidr. borissaki','2.59','0.1'],['Em. plummeri','2.06','0.06'],['Neopr. rotundus','1.25','0.12'],['Neopr. schucherti','1.33','0.08'],['Neopr. tenius','1.45','0.14'],['Sak. asaphus','1.94','0.16'],['Artin. kazakhstanica','1.09','0.25'],['Artin. multituberculata','0.83','0.1'],['Artin. nalivkini','1.05','0.04'],['Agath. uralicum','2.12','0.02'],['Prothal. serratum','1.72','0.01'],['Prothal. biforme','1.8','0.02'],['Arist. appressum','1.92','0.03'],['Eoas. trapezoidalis','4.8','0.57'],['Eoas. vodorezovi','3.03','0.49'],['Eoas. subhanieli','3.47','0.39'],['Eoas. hartmannae','3.21','0.38'],['Jur. primitivus','3.47','0.4'],['Glaph. angustilobatus','3.51','0.38'],['Glaph. rarus','2.59','0.25'],['Sv. serpentinum','2.2','0.6'],['Sv. strigosum','2.29','0.62'],['Paragastr. sterlitamakense','2.49','0.42'],['Paragastr. ellipsoidale','2.75','0.39'],['Protopop. sublahuseni','1.1','0.12'],['Prost. juresanense','1.77','0.1'],['Neogl. satrus','2.52','0.06'],['Boes. serotinus','2.38','0.26'],['Neopr. milleri','1.45','0.1'],['Neopr. tenius','1.45','0.14'],['Neopr. shinini','1.47','0.08'],['Sak. postcarbonarius ','2.23','0.16'],['Sak. ajdaralense','2.03','0.19'],['Sak. inflatus','2.19','0.13'],['Synart. principalis','1.06','0.01'],['Medl. semota','0.97','0.09'],['Agath. uralicum','2.12','0.02'],['Thal. multifidum','2.2','0.03'],['Met. distale ','4.94','0.54'],['Met. noinskyi','4.42','0.5'],['Met. gerassimovi','2.88','0.31'],['Som. shikhanensis','2.97','0.41'],['Som. beluensis','3.43','0.36'],['Andr. sakmarae','3.38','0.36'],['Sv. strigosum','2.29','0.62'],['Paragastr. sintasense','2.55','0.47'],['Paragastr. ultuganense','2.44','0.5'],['Paragastr. kirghizorum','2.51','0.47'],['Synural. carinatum','1.54','0.29'],['Ural. simense','2.59','0.41'],['Ural. burtiense','1.78','0.48'],['Ural. limatulum','1.73','0.48'],['Propop. simense','1.27','0.13'],['Propop. postsimense','1.14','0.08'],['Propop. incallidium','0.99','0.09'],['Cr. subkrotowi','3.81','0.04'],['Dar. elegans','1.88','0.2'],['Neopr. skvorzovi','1.73','0.1'],['Neopr. permicus','2.03','0.18'],['Sak. vulgaris','2.2','0.13'],['Artioc.rhipaeum','1.17','0.04'],['Akt. notabilis','0.76','0.01'],['Art. artiense','0.96','0.04'],['Medl. intermedia','0.85','0.06'],['Medl. orbignyana','0.94','0.04'],['Propin. aktubense','1.04','0.02'],['Agath. uralicum','2.31','0.03'],['Thal. gemmellaroi','2.09','0.03'],['Met. sog. sogurense','5.06','0.59'],['Met. sog. razumowskajae','4.48','0.52'],['Met. sog. inflatum','3.79','0.44'],['Met. rotundatum','4.71','0.45'],['Met. klimovi','3.56','0.45'],['Met. ajdaralense','3.79','0.39'],['Met. evolutum ','3.29','0.42'],['Met. tschernyschewi','3','0.31'],['Neosh. triceps','2.68','0.29'],['Paragastr. tchernowi','2.31','0.42'],['Paragastr. artolobatum','3.28','0.49'],['Paragastr. plicatum','2.01','0.48'],['Paragastr. kirghizorum','2.61','0.48'],['Paragastr. modulatum','2.03','0.5'],['Paragastr. alimbeti','2.08','0.52'],['Paragastr. caducum','2.15','0.58'],['Paragastr. ilovaiskyi','3.14','0.55'],['Paragastr. scitum','2.78','0.45'],['Paragastr. tectum','3.41','0.54'],['Paragastr. ellipsoidale','2.52','0.54'],['Paragastr.joss.subtrapezoidale','2.87','0.51'],['Paragastr. joss. jossae','3.79','0.54'],['Paragastr. joss. exile','2.6','0.5'],['Paragastr. rauserae','3.4','0.56'],['Paragastr. verneuili','2.04','0.36'],['Paragastr. karpinskii','2.74','0.35'],['Ural. gracilentum','2.15','0.53'],['Ural. burtiense','1.76','0.5'],['Ural. involutum','1.78','0.37'],['Ural. complanatum','1.99','0.42'],['Ural. fedorowi','1.63','0.4'],['Ural. vietum','2.28','0.4'],['Ural. extenuatum','1.9','0.5'],['Ural. belgushkense','2.08','0.47'],['Ural. suessi','1.74','0.47'],['Eoth. karg. kargalensis','1.66','0.34'],['Eoth. karg. aktubensis','2','0.42'],['Eoth. stenomphalus','2.33','0.46'],['Eoth. aktastensis','1.86','0.35'],['Waag. subinterrupta','2.22','0.1'],['Pop. tschernowi','1.01','0.1'],['Pop. congregale','1.01','0.08'],['Pop. sintasense','1.04','0.06'],['Pop. annae','1.18','0.07'],['Pop. sobolewskyanum','0.74','0.08'],['Pop. polypetale','1.01','0.09'],['Karg. typicus','2.62','0.06'],['Al. invariabilis','1.76','0.06'],['Al. pressulus','1.91','0.05'],['Cr. krotowi','2.39','0.06'],['Cr. subkrotowi','2.55','0.06'],['Neocr. fredericksi','3.09','0.1']],
	'dataset' : false,
	'boxWidth' : 0,  /* ширина канвы */
	'boxHeight' : 0, /* высота канвы */
	'svg' : false, /* канва, по умолчанию ее нет */
	 

	/*--------------------------------------------------------------сборка-----------------------------------------------------------------------*/
	build: function(){
 		this.boxWidth = objD3.svgsize(this.canvas,'width'); /* задаем ширину канвы */
		this.boxHeight =  objD3.svgsize(this.canvas,'height'); /* задаем высота канвы */
		this.svg = objD3.generateSvg(this.canvas,this.boxWidth,this.boxHeight,[30,30,30,30]);  /*создаем канву (где рисовать, ширина, длина, отступы)*/
		this.toolbar(); /*функции тулбара*/
		objD3.zoom(this.svg); /* включение увеличения */
		this.generatepoints(); /* генерируем точки */
		
		return false;
 	},
	
	/*--------------------------------------------------------------функции тулбара--------------------------------------------------------------*/
	toolbar: function(){
		/* рисуем график W */
		$('body').on('click', '#content-analyses-graph-W', function(){
			objD3.remove(objAnalys.svg,"*");
			objAnalys.generate_graph("W");
		});
		/* рисуем график D */
		$('body').on('click', '#content-analyses-graph-D', function(){
			objD3.remove(objAnalys.svg,"*");
			objAnalys.generate_graph("D");
		});
		/* рисуем график S */
		$('body').on('click', '#content-analyses-graph-S', function(){
			objD3.remove(objAnalys.svg,"*");
			objAnalys.generate_graph("S");
		});
		/* рисуем изолинии */
		$("body").on("click", "#content-analyses-isolines", function() {
			objIsolines.dataset = objAnalys.dataset;
			
			objHelpers.popup3(AVG.lang[AVG.language]['long_construct_isoline'],"warning"); /* окно ожидания */
			//$(this).prop("disabled",true); /* !!!! ВРЕМЕННО !!! УДАЛИТЬ !!! */
			setTimeout(function(){
				objIsolines.makeIsolines(); /* создаем изолинии */
			},500);
 		});
		/* показать/спрятать точки */
		$("body").on("click", "#content-analyses-points", function() {
			if($(this).prop("checked"))	$('.isolines_points').show();
			else $('.isolines_points').hide(); 
						
 		});
		
		$("body").on("click", "#content-analyses-makepoints", function() {
			objAnalys.generatepoints();
		});
		
		/* показать/спрятать подписи к точкам */
		$("body").on("click", "#content-analyses-addlabels", function() {
			if($(this).prop("checked"))	$('.labelstext').show();
			else $('.labelstext').hide(); 

 		});
		/* показать/спрятать гиперболу */
		$("body").on("click", "#content-analyses-hyperbole", function() {
			if($(this).prop("checked"))	$('.hyperbole').show();
			else $('.hyperbole').hide(); 
 		});
		/* количество изолини */
		$("body").on("input", ".content-analyses .content-toolbar-range", function() {
				var value = $(this).val();
				$(this).next('span').html(value);
		});
		return false;
	},
	
	/*--------------------------------------------создание Axis, генерация точек, гиперболы и текста---------------------------------------------*/
	generatepoints: function(){
		
		//console.log(this.dataset);
		
		objD3.remove(this.svg,"*"); /* очищаем канву */ 
		
		var zoom = d3.behavior.zoom()
			.scaleExtent([1, 10])
			.on("zoom", zoomed);
		
		this.svg.call(zoom);
		
		 
		
		function zoomed() {
			d3.select(".graph").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
			  
			/*пропорциональное изменение размеров точек*/
			var rad = 5/d3.event.scale;
			d3.selectAll(".isolines_points").attr("r", rad)
						.on("mouseover", function() {
							d3.select(this)   .transition()
							.duration(100).attr('r', rad*2)
						})
						.on("mouseout", function() {
							d3.select(this).transition()
								.duration(100)
								.attr('r', rad);
						});
			var txtSize = 10/d3.event.scale;			
			
			d3.selectAll(".labelstext")
 						.attr("font-size",txtSize+"px");
						
			  
		}
		
		var container = this.svg.append("g").attr("class","graph").style("cursor","move");
		
		/* параметры для Axis */
		var param_axis = {
			'svg' : container,
			'width' : this.boxWidth,
			'height' : this.boxHeight,
			'minY' : 0.5,
			'maxY' : 5.5,
			'rangY1' : 0,
			'rangY2' : this.boxHeight-50,
			'minX' : 0,
			'maxX' : 0.7,
			'rangX1' : 0,
			'rangX2' : this.boxWidth,
 			'inTickSizeY' : -6,
			'ticPadY' : -17,
			'inTickSizeX' : 3,
			'ticPadX' : false,
			'labels' : [
					{ 'x' : 0.63, 'y' : 5.4, 'text' : 'W'},
					{ 'x' : -0.01, 'y' : 0.40, 'text' : 'D'},
				],
 		};
		
		objD3.drawAxis(param_axis); /* рисуем Axis */
		
		/* форма и интерополяция линий */	
		var lineFunction = d3.svg.line()
                    .x(function(d) { return xScale(d[0]); })
                    .y(function(d) { return yScale(d[1]); })
                    .interpolate("basis");
		
		/* шкала Y */
		var yScale = d3.scale.linear()
					.domain([param_axis.minY, param_axis.maxY])
					.range([param_axis.rangY1, param_axis.rangY2]);
		
		/* шкала X */
		var xScale = d3.scale.linear()
					.domain([param_axis.minX, param_axis.maxX])
					.range([param_axis.rangX1, param_axis.rangX2]);	
		
		
		
		
		
		/* рисуем точки из главного массива данных this.dataset */
		container.selectAll("circle")
						.data(this.dataset)
						.enter()
						.append("circle")
						.attr("cx", function(d) {	return xScale(d[2]);    })
						.attr("cy", function(d) {  	return yScale(d[1]);    })
						.attr("r", "5")
						.attr("class","isolines_points")
						.on("mouseover", function() {
							d3.select(this)   .transition()
							.duration(100).attr('r', 10)
						})	
						.on("mouseout", function() {
							d3.select(this).transition()
								.duration(100)
								.attr('r', 5);
						});
						
						
		console.log(this.dataset);				
						
		/* сразу добавляем текстовые подписи, скрываем в CSS*/				
		container.selectAll("text")
                        .data(this.dataset)
                        .enter()
                        .append("text")
						.attr("x", function(d) { return xScale(d[2]);    })
						.attr("y", function(d) { return yScale(d[1]);    })
						/*.text( function (d) { return d[2]; })*/
						.text(function (d) {  return d[0]; })
						.attr("font-size","10px")
 						.attr("class","labelstext");
		

		/* гипербола */
		var hyperbole = objD3.hyperbole(0.182,0.7,0.01);	/* получаем массив точек для гиперболы  */	 
		/* рисуем гиперболу */
		container.append("path")
					.datum(hyperbole)
					.attr("d", lineFunction)
					.attr("class","hyperbole");
			
		return false;
	},
	
	/*-------------------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------- ГРАФИКИ W,D,S -------------------------------------------------------------------------*/
	/*-------------------------------------------------------------------------------------------------------------------------------------------*/
	/*-------------------формирование массива минимальное, максимальное, шаг, номер колонки массива----------------------------------------------*/
	get_arr_curve: function(min,max,step,num_row){
		var curve = [];
		var arr_points = objAnalys.dataset;
		var arr_iteration = [];
		/* массив значений окрестностей для W,D,S и прочего */
		var arr_places = [];
		/* формируем массив окрестностей и итераций сравнений */
		for (var d=min; d<=max; d=d+step){
			arr_places.push([d,(d+(d+step))/2,d+step]);
			arr_iteration.push(0);
		}
		/* обсчет массива по итерациям */
		for(var i=0; i < arr_points.length; i++){
			for (var s=0; s < arr_iteration.length; s++){
				if (arr_places[s][0]<arr_points[i][num_row] && arr_points[i][num_row]<=arr_places[s][2]) arr_iteration[s] = arr_iteration[s]+1;
			}
		}

		
		
		/* собираем новый массив для отправки [x, value] */
		var arr_return = [];
		arr_return[0] = [[min,0]];
		arr_return[1] = Math.max.apply(Math, arr_iteration); 
		for(var p=0; p < arr_iteration.length; p++){
			arr_return[0].push([arr_places[p][1],arr_iteration[p]]);
		}
		
		 
		return arr_return;
	},
	
	/*----------------------------------------------------рисование графиков---------------------------------------------------------------------*/	
	generate_graph: function(param){
		objD3.remove(this.svg,"*"); /* очищаем канву */ 
		/* получаем параметры для графика */ 
		var obj = objAnalys.graphparam;  
		/* строим в звисимости от param массив данных */
		var curve = objAnalys.get_arr_curve(obj[param].min,obj[param].max,obj[param].step,obj[param].num_col); 
		if (curve[1]>0){
	
			/* параметры Axis */
			var param_axis = {
				'svg' : this.svg,
				'width' : this.boxWidth,
				'height' : this.boxHeight,
				'minY' : curve[1]+1,
				'maxY' : 0,
				'rangY1' : 0,
				'rangY2' : this.boxHeight-50,
				'minX' : obj[param].min,
				'maxX' : obj[param].max,
				'rangX1' : 0,
				'rangX2' : this.boxWidth,
				'inTickSizeY' : -6,
				'ticPadY' : -17,
				'inTickSizeX' : 3,
				'ticPadX' : false,
				'labels' : [
						{ 'x' : obj[param].min, 'y' : curve[1]+2, 'text' : 'количество экземляров'},
						{ 'x' : obj[param].max-obj[param].step, 'y' : 1, 'text' : param},
					],
			};
			
			objD3.drawAxis(param_axis); /* рисуем Axis */
			
			/* шкала и рисование самих графиков */
			var yScale = d3.scale.linear().domain([param_axis.minY, param_axis.maxY]).range([param_axis.rangY1, param_axis.rangY2]);
			var xScale = d3.scale.linear().domain([param_axis.minX, param_axis.maxX]).range([param_axis.rangX1, param_axis.rangX2]);
			
			var lineFunction = d3.svg.line()
						.x(function(d) { return xScale(d[0]); })
						.y(function(d) { return yScale(d[1]); })
						.interpolate("basis");
			
			this.svg.append("path")
				.datum(curve[0])
				.attr("d", lineFunction)
				.attr("class","curve");
		}else{
			objHelpers.popup(AVG.lang[AVG.language]['not_data'],"error");
		}
		return false;

	},

	
};


