Commit 32b3f5bf authored by Axel Auweter's avatar Axel Auweter
Browse files

Fix dcdbplot on Mac (mktemp)

Add -p parameter for plotting data points
Don't sort temp files to avoid confusion with timestamps of differing number of digits (should be unnecessary since data comes sorted from the db anyways).
parent c74c2caa
......@@ -5,6 +5,7 @@ TMP=""
INFILETMP=0
ZEROOFFSET=0
LINES="lines"
SMOOTH=""
CLEANTEMP=1
LOCALTIME=0
......@@ -12,6 +13,8 @@ LOCALTIME=0
if [ "$#" -ge "1" ]; then
while [ "${1:0:1}" == "-" ]; do
case ${1:1:1} in
p) LINES="linespoints"
;;
b) SMOOTH="smooth bezier"
;;
c) SMOOTH="smooth csplines"
......@@ -31,12 +34,13 @@ fi
if [ -t 0 ]; then
if [ "$#" -lt "1" ]; then
echo "Usage: dcdbplot [-z] [infile] [outfile]"
echo "Usage: dcdbplot [options] [infile] [outfile]"
echo ""
echo "Parameters:"
echo " infile CSV input data, may be piped to stdin"
echo " outfile optional PNG output file (X11 is default output)"
echo ""
echo " -p Mark points in graph"
echo " -b Smooth graph with Bezier curves"
echo " -c Smooth graph with csplines"
echo " -z Start y-axis at 0"
......@@ -68,7 +72,7 @@ if [ ! -e $INFILE ]; then
fi
# Create tmp dir
TMP=`mktemp --tmpdir -d dcdbplot.XXXXXX`
TMP=`mktemp -d dcdbplot.XXXXXX`
# Get length of file
L=`cat $INFILE | wc -l`
......@@ -90,7 +94,7 @@ echo "$S"
A=0
while read -r i; do
echo "Creating $TMP/$i".dat
grep "$i" $INFILE | sort > "$TMP/$i".dat
grep "$i" $INFILE > "$TMP/$i".dat
A=$((A+1))
done <<< "$S"
......@@ -156,7 +160,7 @@ plot \\
EOF
while read -r i; do
echo -n "'$TMP/${i}.dat2' using 2:3 title '$i' with lines $SMOOTH" >> $TMP/plot.gplt
echo -n "'$TMP/${i}.dat2' using 2:3 title '$i' with $LINES $SMOOTH" >> $TMP/plot.gplt
if [ "$A" -gt "1" ]; then
echo ", \\" >> $TMP/plot.gplt
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment