import River_Ayuthaya
import River_Bangsai
import River_Chainat
import River_Dowkanong
import River_Nakhonsawan
import River_Pamok
import River_Samlae
from nvd3 import lineChart

list_date_ay, list_do, list_ec, list_temp_ay, av_do, av_ec, av_temp = River_Ayuthaya.data_split()
list_date_bs, list_do, list_ec, list_temp_bs, av_do, av_ec, av_temp= River_Bangsai.data_split()
list_date_ch, list_do, list_ec, list_temp_ch, av_do, av_ec, av_temp = River_Chainat.data_split()
list_date_dk, list_do, list_ec, list_temp_dk, av_do, av_ec, av_temp = River_Dowkanong.data_split()
list_date_nk, list_do, list_ec, list_temp_nk, av_do, av_ec, av_temp = River_Nakhonsawan.data_split()
list_date_pm, list_do, list_ec, list_temp_pm, av_do, av_ec, av_temp = River_Pamok.data_split()
list_date_sl, list_do, list_ec, list_temp_sl, av_do, av_ec, av_temp = River_Samlae.data_split()

def average_per_day(valu, date):  
    list_average = []
    list_date = []
    for i in date:
        day = i.split()
        list_date.append(int(day[0][1:]))
    # fix constant
    cons = list_date[0]
    aver = 0
    time = 0
    for i in range(len(list_date)):
        if list_date[i] == cons:
            if valu[i] == 'F':
                pass
import River_Ayuthaya
import River_Bangsai
import River_Chainat
import River_Dowkanong
import River_Nakhonsawan
import River_Pamok
import River_Samlae
from nvd3 import discreteBarChart

list_date, list_do, list_ec, list_temp, ave_do_ayuthaya, ave_ec_ayuthaya, ave_temp_ayuthaya = River_Ayuthaya.data_split()
list_date, list_do, list_ec, list_temp, ave_do_bangsai, ave_ec_bangsai, ave_temp_bangsai = River_Bangsai.data_split()
list_date, list_do, list_ec, list_temp, ave_do_chainat, ave_ec_chainat, ave_temp_chainat = River_Chainat.data_split()
list_date, list_do, list_ec, list_temp, ave_do_dowkanong, ave_ec_dowkanong, ave_temp_dowkanong = River_Dowkanong.data_split()
list_date, list_do, list_ec, list_temp, ave_do_nakhonsawan, ave_ec_nakhonsawan, ave_temp_nakhonsawan = River_Nakhonsawan.data_split()
list_date, list_do, list_ec, list_temp, ave_do_pamok, ave_ec_pamok, ave_temp_pamok = River_Pamok.data_split()
list_date, list_do, list_ec, list_temp, ave_do_samlae, ave_ec_samlae, ave_temp_samlae = River_Samlae.data_split()
#print(ave_do_ayuthaya, ave_do_bangsai, ave_do_chainat, ave_do_dowkanong, ave_do_nakhonsawan, ave_do_pamok, ave_do_samlae)
all_ave_do = [ave_do_ayuthaya, ave_do_bangsai, ave_do_chainat, ave_do_dowkanong, ave_do_nakhonsawan, ave_do_pamok, ave_do_samlae]
all_ave_ec = [ave_ec_ayuthaya, ave_ec_bangsai, ave_ec_chainat, ave_ec_dowkanong, ave_ec_nakhonsawan, ave_ec_pamok, ave_ec_samlae]
all_ave_temp = [ave_temp_ayuthaya, ave_temp_bangsai, ave_temp_chainat, ave_temp_dowkanong, ave_temp_nakhonsawan, ave_temp_pamok, ave_temp_samlae]

#created HTML
def ave_do_chart():
    output_file = open('Average-DO.html', 'w')
    chart = discreteBarChart(name='discreteBarChart of average D.O.', width=1244)

    xdata = ["Ayuthaya", "Bangsai", "Chainat", "Dowkanong", "Nakhonsawan", "Pamok", "Samlea"]
    ydata = all_ave_do

    extra_serie = {"tooltip": {"y_start": "", "y_end": "m/L"}}
    chart.add_serie(y=ydata, x=xdata, name='D.O.', extra=extra_serie)