Created
April 28, 2011 01:33
Revisions
-
chriscoyier revised this gist
Apr 30, 2011 . 1 changed file with 24 additions and 16 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,14 +14,16 @@ #chart { margin: 0 auto; padding: 100px 0; height: 400px; position: relative; text-align: center; } #chart > a { width: 1px; /* Fallback color */ background: orange; /* Way cooler gradient */ background: -webkit-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -moz-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -ms-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -o-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); display: inline-block; vertical-align: bottom; text-decoration: none; } @@ -44,6 +46,9 @@ #chart > a:hover > span { opacity: 1; } #chart strong { padding: 10px; } </style> </head> @@ -55,7 +60,6 @@ $query = "SELECT comment_count FROM " . $wpdb->posts . " WHERE post_type = 'post' && post_status = 'publish' ORDER BY comment_count DESC LIMIT 1"; $results = $wpdb->get_results($query); $maxComments = $results[0]->comment_count; query_posts('posts_per_page=-1&order=ASC'); @@ -68,25 +72,29 @@ while (have_posts() ) : the_post(); // Echo the first year post published if ($i == 1) { echo "<strong>"; the_date("Y"); echo "</strong>"; // prevent from outputting next iteration $i = 0; } $numComments = get_comments_number(); $heightPercentage = (($numComments / $maxComments) * 100); echo "<a href='"; echo get_permalink(); echo "' style='height: $heightPercentage%;'>"; echo "<span>$numComments</span>"; echo "</a>"; endwhile; // Echo the last year post published echo "<strong>"; the_date("Y"); echo "</strong>"; ?> -
chriscoyier revised this gist
Apr 30, 2011 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,11 +16,13 @@ width: 1px; background: red; background: -webkit-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -moz-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -ms-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: -o-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); background: linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); display: inline-block; vertical-align: middle; text-decoration: none; } #chart > a:hover { -
chriscoyier revised this gist
Apr 29, 2011 . 1 changed file with 61 additions and 9 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,31 +11,83 @@ <title>Comment Graph</title> <style> #chart { margin: 0 auto; padding: 100px 0; height: 400px; position: relative; text-align: center; } #chart > a { width: 1px; background: red; background: -webkit-linear-gradient(top, hsl(27, 95%, 45%), hsl(27, 95%, 65%), hsl(27, 95%, 45%)); display: inline-block; vertical-align: middle; text-decoration: none; -webkit-transition: width 0.2s ease; text-decoration: none; } #chart > a:hover { background: black; } #chart span { width: 50px; background: black; color: white; text-align: center; padding: 10px; position: absolute; top: 0; left: 50%; margin-left: -30px; opacity: 0; z-index: 1; } #chart > a:hover > span { opacity: 1; } </style> </head> <body> <?php $i = 1; $query = "SELECT comment_count FROM " . $wpdb->posts . " WHERE post_type = 'post' && post_status = 'publish' ORDER BY comment_count DESC LIMIT 1"; $results = $wpdb->get_results($query); $maxComments = $results[0]->comment_count; query_posts('posts_per_page=-1&order=ASC'); ?> <div id="chart"> <?php while (have_posts() ) : the_post(); // Echo the first year post published if ($i == 1) { echo "<strong>" . the_date("Y") . "</strong>"; } $numComments = get_comments_number(); $heightPercentage = (($numComments / $maxComments) * 100); echo "<a href='"; echo get_permalink(); echo "' style='height: $heightPercentage%;'>"; // echo strip_tags(get_the_title()); echo "<span>$numComments</span>"; echo "</a>"; $i++; endwhile; // Echo the last year post published echo "<strong>" . the_date("Y") . "</strong>"; ?> </div> </body> -
chriscoyier renamed this gist
Apr 28, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chriscoyier created this gist
Apr 28, 2011 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ <?php /* Template Name: Comment Graph */ ?> <!DOCTYPE html> <html> <head> <meta charset=utf-8> <title>Comment Graph</title> <style> #chart { margin: 50px 0; height: 400px; } #chart > div { width: 1px; background: red; display: inline-block; } </style> </head> <body> <?php query_posts('posts_per_page=-1'); ?> <div id="chart"> <?php while (have_posts() ) : the_post(); $numComments = get_comments_number(); $percentage = $numComments / 3; echo "<div style='height: $percentage%;'></div>"; endwhile; ?> </div> </body> </html>