export function Chart(){
  this.series = [];
  this.title = '';
  this.divitions = [];
  this.measure = '';
  this.container = '';
  this.options = null;
};

export function setContainer(container) {
  this.container = '#'+container;
};

export function setTitle(title) {
  this.title = title;
};

export function setSeries(series) {
  this.series = series;
};

export function setDivitions(divitions) {
  this.divitions = divitions;
}

export function setMeasure(measure) {
  this.measure = measure;
}

export function setOptions(options) {
  this.options = options;
};

export function Draw() {

  var title       = this.title;
  var series      = this.series;
  var divitions   = this.divitions;
  var measure     = this.measure;

  // var options =  this.options;

  var chart = {
    chart:{
      height: 350
    },
    title: {
      text: title
    },
    credits: {
      enabled: false
    },
    legend: {
      borderWidth: 2,
      borderRadius: 3
    },
    lang: {
      noData: "Datos Insuficientes."
  },
    tooltip: {
      // shared: true,
      enabled: true,
      // crosshairs: true
    },
    xAxis: {
      categories: divitions
    },
    yAxis: [{
      title: { text: measure },
      min:0,
      max:2000
    }, {
      title: { text: measure },
      min:0,
      max:10000,
      opposite: true
    }],
    series: series
    }

  if(this.options!==null){
		chart = $.extend(true, chart, this.options);
    $(this.container).highcharts(chart);
	}

  return chart;
}

export function Destroy() {
	if (this.chart !== null) {
		this.chart = null;
	}

	this.title = '';
	this.series = [];
  this.divitions = [];
  this.measure = '';
  this.container = '';
  this.options = null;
}
