Plugin Directory

Changeset 735258


Ignore:
Timestamp:
07/03/2013 01:27:21 AM (13 years ago)
Author:
randyjensen
Message:

added ability to set custom height and database upgrade

Location:
rj-quickcharts/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • rj-quickcharts/trunk/README.txt

    r734808 r735258  
    77Requires at least: 3.3
    88Tested up to: 3.5
    9 Stable tag: 0.4.2
     9Stable tag: 0.4.3
    1010
    1111Create incredible HTML5/JavaScript charts right inside WordPress with a few clicks.
     
    4444== Changelog ==
    4545
     46= 0.4.3 =
     47* Ability to set the chart height
     48
    4649= 0.4.2 =
    4750* Only Admins and Editors can edit charts now
  • rj-quickcharts/trunk/admin/rjqc-admin-new.php

    r732254 r735258  
    11<?
    2 //wp_enqueue_script('ajax-script', plugins_url( '/main.js?v='.rand() ), array('jquery'));
    3 
    42$type           = '';
    53$title          = '';
     
    75$tooltip_suffix = '';
    86$y_axis_title   = '';
     7$chart_height   = '300';
    98
    109$id = $_GET['id'];
     
    2423    $series         = $chart[0]->series;
    2524    $hotSeries      = $chart[0]->hotSeries;
     25    $opts           = json_decode($chart[0]->opts);
     26    $chart_height   = $opts->height;
    2627
    2728    echo '<input id="rjqc-chart-id" type="hidden" value="'.$id.'" />';
     
    6465                <label id="chart-tooltip-suffix"><span>Tooltip Suffix</span><br />
    6566                    <input type="text" placeholder="&deg;C" value="'.$tooltip_suffix.'" />
     67                </label>
     68                <label id="chart-height"><span>Chart Height (leave empty for default)</span><br />
     69                    <input type="text" placeholder="300" value="'.$chart_height.'" />px
    6670                </label>
    6771            </form>
     
    9094        <h3 class="hndle"><span>Step 3: Preview</span></h3>
    9195        <div class="inside">
    92                 <div id="rjqc-chart" style="height:300px;"></div>
     96                <div id="rjqc-chart" style="height:'.$chart_height.'px;"></div>
    9397            <div class="cf"></div>
    9498        </div>
     
    387391    });
    388392
     393    // Change the chart Height
     394    jQuery('#chart-height input').keyup(function() {
     395        chartHeight = jQuery(this).val();
     396        if (chartHeight === '') {
     397            jQuery('#rjqc-chart').height('300px');
     398        } else {
     399            jQuery('#rjqc-chart').height(chartHeight+'px');
     400        }
     401        chart.replot();
     402    });
     403
    389404    <? if ($_GET['id']) { ?>
    390405    if (<? echo $legend ?> === 0) {
  • rj-quickcharts/trunk/ajax/ajax.js

    r732243 r735258  
    7272            tooltip_suffix  = $('#chart-tooltip-suffix input').val(),
    7373            y_axis_title    = $('#chart-yaxis-title input').val(),
     74            height          = $('#chart-height input').val(),
    7475            y_axis_cats     = theYCats,
    7576            series          = theYData,
    7677            hotSeries       = theData;
     78
     79        if (height === '') {
     80            height = 300;
     81        }
    7782
    7883        var data = {
     
    8590            y_axis_cats: y_axis_cats,
    8691            series: series,
    87             hotSeries: theData
     92            hotSeries: theData,
     93            opts: {
     94                height: height
     95            }
    8896        };
    8997
  • rj-quickcharts/trunk/ajax/init.php

    r727478 r735258  
    5656                $y_axis_title   = $_POST['y_axis_title'];
    5757                $y_axis_cats    = json_encode($_POST['y_axis_cats']);
    58                 //$series         = json_encode($_POST['series'], JSON_NUMERIC_CHECK);
    59                 //$hotSeries      = json_encode($_POST['hotSeries'], JSON_NUMERIC_CHECK);
    6058                $series         = json_encode($full_series);
    6159                $hotSeries      = json_encode($full_hot_series);
     60                $opts           = json_encode($_POST['opts']);
    6261
    6362                $rows = $wpdb->insert(
     
    7271                                    'legendOn' => $legend,
    7372                                    'series' => $series,
    74                                     'hotSeries' => $hotSeries )
     73                                    'hotSeries' => $hotSeries,
     74                                    'opts' => $opts )
    7575                                );
    7676
     
    103103                $series         = $chart[0]->series;
    104104                $hotSeries      = $chart[0]->hotSeries;
     105                $opts           = $chart[0]->opts;
    105106
    106107                $wpdb->insert(
     
    115116                        'legendOn' => $legend,
    116117                        'series' => $series,
    117                         'hotSeries' => $hotSeries
     118                        'hotSeries' => $hotSeries,
     119                        'opts' => $opts
    118120                    )
    119121                );
     
    131133                        "legendOn":'.json_encode($legend).',
    132134                        "series":'.json_encode($series).',
    133                         "hotSeries":'.json_encode($hotSeries).'
     135                        "hotSeries":'.json_encode($hotSeries).',
     136                        "opts":'.json_encode($opts).'
    134137                    }';
    135138                die;
     
    177180                        'xAxisCats'     => json_encode($_POST['y_axis_cats']),
    178181                        'legendOn'      => (int)$_POST['legend'],
    179                         //'series'      => json_encode($_POST['series'], JSON_NUMERIC_CHECK),
    180                         //'hotSeries'   => json_encode($_POST['hotSeries'], JSON_NUMERIC_CHECK)
    181182                        'series'        => json_encode($full_series),
    182                         'hotSeries'     => json_encode($full_hot_series)
     183                        'hotSeries'     => json_encode($full_hot_series),
     184                        'opts'          => json_encode($_POST['opts'])
    183185                    ),
    184186                    array('id'=>$id)
  • rj-quickcharts/trunk/rj_charts.php

    r734806 r735258  
    44Plugin URI: http://www.randyjensen.com
    55Description: Easily create charts for your WordPress site. Line charts, bar charts and pie charts currently supported.
    6 Version: 0.4.2
     6Version: 0.4.3
    77Author: Randy Jensen
    88Author URI: http://www.randyjensen.com
     
    1515    global $table_name;
    1616
    17     $rjqc_db_version = '0.4.2';
     17    $rjqc_db_version = '0.4.3';
    1818    $table_name = $wpdb->prefix . 'rj_quickcharts';
    1919
     
    5353        {
    5454            global $table_name;
     55            global $rjqc_db_version;
    5556
    5657            $sql = "CREATE TABLE $table_name (
     
    6667                series longtext NOT NULL,
    6768                hotSeries longtext NOT NULL,
     69                opts longtext NOT NULL,
    6870                UNIQUE KEY id (id)
    6971            );";
     
    7173            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    7274            dbDelta( $sql );
     75
     76            // Is there an upgrade? Make sure they have the latest database
     77            $installed_ver = get_option("rjqc_db_version");
     78
     79            if($installed_ver != $rjqc_db_version) {
     80
     81                $sql = "CREATE TABLE $table_name (
     82                    id int(16) NOT NULL AUTO_INCREMENT,
     83                    created datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     84                    type char(50) NOT NULL DEFAULT 'line',
     85                    title varchar(200) NOT NULL,
     86                    subtitle varchar(200) NOT NULL,
     87                    tooltipSuffix varchar(200) NOT NULL,
     88                    yAxisTitleText varchar(200) NOT NULL,
     89                    xAxisCats longtext NOT NULL,
     90                    legendOn int(0) NOT NULL,
     91                    series longtext NOT NULL,
     92                    hotSeries longtext NOT NULL,
     93                    opts longtext NOT NULL,
     94                    UNIQUE KEY id (id)
     95                );";
     96
     97                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     98                dbDelta($sql);
     99
     100                update_option("rjqc_db_version", $rjqc_db_version);
     101            }
    73102        }
    74103
     
    96125    register_deactivation_hook(__FILE__, array('RJ_Quickcharts', 'deactivate'));
    97126
    98     $rj_quickcharts = new RJ_Quickcharts();
     127    function rjqc_update_db_check() {
     128        global $rjqc_db_version;
     129        if (get_site_option( 'rjqc_db_version' ) != $rjqc_db_version) {
     130            RJ_Quickcharts::activate();
     131        }
     132    }
     133    add_action( 'plugins_loaded', 'rjqc_update_db_check' );
     134
     135    $rj_quickcharts = new RJ_Quickcharts();
    99136
    100137    // Add a link to the settings page onto the plugin page
  • rj-quickcharts/trunk/shortcode/init.php

    r732243 r735258  
    4141                $hotSeries  = $chart[0]->hotSeries;
    4242                $chartFill  = false;
     43                $opts       = json_decode($chart[0]->opts);
     44                $chartHeight= $opts->height;
    4345
    4446                if ($type == "pie") {
     
    9597                }
    9698
    97                 $return_string .= "<div id='rjqc_container_$id'></div>";
     99                $return_string .= "<div id='rjqc_container_$id' style='height:".$chartHeight."px'></div>";
    98100                $return_string .= "<script>";
    99101                $return_string .= "(function ($) {
Note: See TracChangeset for help on using the changeset viewer.