Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • What do you mean by change them?

    The Y axis is connected to the data in the bar…?

    You’re really going to have to be more specific.

    …Care to elaborate?

    You’ve not mentioned the error, or any information. Nobody is going to be able to help you :/.

    You can dynamically build the shortcode with PHP, so if you can access the remote database okay, yes, you can feed it to WP charts.

    After a quick Google, something similar to the below may do the trick to get you connected. Obviously you will need to know the structure of the DB if you wish to query it!

    <?php
    
    mysql_connect("mysite.com:3306", "admin", "1admin") or die(mysql_error());
    echo "Connected to MySQL<br />";
    
    ?>

    Never tried it myself mind!

    Hope this helps,

    Ryan

    I’ve done mine like this and it works for me, (I’ve deleted all the labels and settings to make it clearer). I only dynamically fill the ‘datasets’ and/or labels, not the whole shortcode.

    <div><?php
    echo do_shortcode('[wp_charts title="twitterChart" animation="false" type="line" datasets="' . $data . '" labels="xxx"]');
    ?></div>

    Here try this for your situation, obviously change $data to fill with your MySQL query.

    $data = "98,94,90,89,88";
    
    echo do_shortcode('[wp_charts title="barchart" type="bar" align="alignleft" margin="5px 20px" datasets="' . $data . '"]');

    I haven’t tested this but it works on mine, if there’s any errors just echo out your $data to ensure your foreach loop is building $data correctly.

    If that doesn’t work, look at possibly changing your foreach loop for a for loop? I personally build my query with the below because my columns are numbered from 1 > 100:

    $sql = "SELECT * FROM temperatur WHERE area = ‘london’ LIMIT 1″;
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_assoc($result);

    for ($x=1; $x<=100; $x++) {
    $data .= $row[‘$x’] . “,”;
    };

    echo $data;`

    Hope this sets you on the right path! The dev of this app seems to have died so thought I’d try help.

    Ryan

    Have you given each chart a unique title?

Viewing 5 replies - 1 through 5 (of 5 total)