Skip to content
Snippets Groups Projects
Commit 9d3ecb86 authored by iehl1g23's avatar iehl1g23
Browse files

Delete graph.sh

parent abc64b71
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Database credentials
DB_USER="root"
DB_PASS="password"
DB_NAME="bitcoin_tracker"
# Get today's date in YYYY-MM-DD format
today=$(date +'%Y-%m-%d')
# Temporary file for storing the data
temp_file="temp_data.txt"
# Query to get the timestamp and price for today
mysql -u "$DB_USER" -p"$DB_PASS" -D "$DB_NAME" -e "SELECT UNIX_TIMESTAMP(timestamp), price FROM bitcoin_and_other_prices WHERE DATE(timestamp) = '$today' ORDER BY timestamp" > "$temp_file"
# Format the data for gnuplot (remove the first line containing column names)
tail -n +2 "$temp_file" > "formatted_data.txt"
# Create plots using gnuplot
gnuplot << EOF
set terminal pngcairo size 800,600 enhanced font 'Arial,10'
set output 'price_$today.png'
set title 'Bitcoin Price vs Time ($today)'
set xlabel 'Time'
set ylabel 'Price (USD)'
# Set the time format for the x-axis
set timefmt "%s" # Input format is Unix timestamp (seconds since 1970)
set xdata time # Use time for the x-axis
set format x "%H:%M" # Format x axis as hour:minute
# Use the formatted data
plot 'formatted_data.txt' using 1:2 with linespoints title 'Price'
EOF
# Clean up temporary files
rm "$temp_file" "formatted_data.txt"
echo "Price graph for today generated successfully!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment