diff --git a/dabo/functions/genchart.sh b/dabo/functions/genchart.sh
new file mode 100644
index 0000000..3df1687
--- /dev/null
+++ b/dabo/functions/genchart.sh
@@ -0,0 +1,105 @@
+function genchart {
+ # generate css chart (line diagram) from csv file or simple file with number per line - needed charts.css included in webppage
+ local mark
+ local lastmark
+ local file=$1
+ local lastlines=$2
+ [ -z "${lastlines}" ] && lastlines=50
+ local fields=$3
+ [ -z "${fields}" ] && fields=1
+ local colors=$4
+ [ -z "${colors}" ] && colors="White,Gold,Silver,Blue,DarkMagenta,DarkViolet,Indigo,MediumBlue,DarkOrchid,MidnightBlue,CornflowerBlue,CadetBlue,DarkCyan,DarkSlateBlue,DeepSkyBlue,DodgerBlue,Teal"
+
+ local awkfields=$(echo "${fields}" | sed 's/,/ \",\" \$/g; s/^/\$/')
+ #tail -n ${lastlines} "${file}" | cut -d, -f${fields} | egrep "^[-0-9]" >${g_tmp}/g_genchart_data
+ tail -n ${lastlines} "${file}" | awk -F',' "{ print $awkfields }" | perl -pe 's/,,+//g' | egrep "^[-0-9]" >${g_tmp}/g_genchart_data
+ lines=$(cat ${g_tmp}/g_genchart_data | wc -l)
+ #head -n1 "${file}" | cut -d, -f${fields} >${g_tmp}/g_genchart_headline
+ head -n1 "${file}" | awk -F',' "{ print $awkfields }" >${g_tmp}/g_genchart_headline
+
+ local time_from=$(tail -n ${lastlines} "${file}" | head -n1 | cut -d, -f1)
+ local time_to=$(tail -n1 "${file}" | cut -d, -f1)
+
+ local highest=$(cat ${g_tmp}/g_genchart_data | sed 's/,/\n/g' | sort -n | egrep "^[-0-9]" | tail -n1 | sed 's/^-//')
+ local lowest=$(cat ${g_tmp}/g_genchart_data | sed 's/,/\n/g' | sort -n | egrep "^[-0-9]" | head -n1)
+ if echo ${lowest} | grep -q '^-'
+ then
+ lowest=$(echo ${lowest} | sed 's/^-//')
+ local calc="+ ${lowest}) / (${highest} + ${lowest}"
+ local calcnull="(0 $calc)"
+ else
+ local calc="- ${lowest}) / (${highest} - ${lowest}"
+ local calcnull="0"
+ fi
+
+ #local divideby=$(echo "$highest+$lowest" | bc -l | sed 's/^\./0./; s/^-\./-0./')
+
+ local fieldsnum=$(cat ${g_tmp}/g_genchart_headline | sed 's/,/\n/g' | wc -l)
+
+ local color="green"
+ tail -n1 ${g_tmp}/g_genchart_data | cut -d, -f1 | grep -q "^-" && color="red"
+
+ mkdir ${g_tmp}/g_genchart
+ local RND=$RANDOM
+ echo "
"
+ echo ""
+ echo " $RND "
+ local line
+ for fieldnum in $(seq ${fieldsnum} | tac)
+ do
+ linecolor=$(echo "$colors" | cut -d, -f${fieldnum})
+ linename=$(cat ${g_tmp}/g_genchart_headline | cut -d, -f${fieldnum} | tr [:lower:] [:upper:])
+ if [ ${fieldnum} -eq 1 ]
+ then
+ echo "${linename} "
+ else
+ echo "${linename} "
+ fi >>${g_tmp}/g_genchart/legend
+ local linenum=1
+ for line in $(cat ${g_tmp}/g_genchart_data)
+ do
+ for mark in $(echo ${line} | cut -d, -f${fieldnum})
+ do
+ [ -z "${lastmark}" ] && lastmark=${mark}
+ local calcstart="(${lastmark} ${calc})"
+ local calcend="(${mark} ${calc})"
+ if [ ${fieldnum} -eq 1 ]
+ then
+ echo " | "
+ echo " ${mark} | "
+ else
+ echo " | "
+ fi >>${g_tmp}/g_genchart/${linenum}
+ ((linenum=linenum+1))
+ lastmark=${mark}
+ done
+ done
+ done
+
+ # put all lines together
+ for linenum in $(seq 2 ${lines})
+ do
+ echo ""
+ cat ${g_tmp}/g_genchart/${linenum}
+ echo " "
+ done
+ echo " "
+
+ # legend
+ if grep -q ',' ${g_tmp}/g_genchart_headline
+ then
+ echo " | "
+ tac ${g_tmp}/g_genchart/legend
+ echo " | "
+ fi
+
+ if echo ${time_from} | egrep -q '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]' && echo ${time_to} | egrep -q '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]'
+ then
+ echo "
| | "
+ fi
+
+ echo "
"
+
+ rm -r ${g_tmp}/g_genchart
+
+}