jeethghambole
Forum Replies Created
-
hi tcclinics,
Can you please help me, i have written the following code for dynamic update but the chart is not showing up.
<?php
function psm_filter_charts_data( $data, $chart_id, $type )
{
// Connect to MySQL
$link = mysql_connect( ‘localhost’, ‘root’, ‘root’ );
if ( !$link )
{
die( ‘Could not connect: ‘ . mysql_error() );
}// Select the data base
$db = mysql_select_db( ‘test’, $link );
if ( !$db )
{
die ( ‘Error selecting database \’test\’ : ‘ . mysql_error() );
}// Fetch the data
$query = ” SELECT category, value1 FROM my_chart_data ORDER BY category ASC”;
$result = mysql_query( $query );
while ( $row = mysql_fetch_assoc( $result ))
{
$data = array(
array(
“Date”, // the value of the first series
$row[‘category’]
),
array(
“Data”, // the value of the first series
$row[‘value1’]
),
);
echo $row[‘category’];
}return $data;
}
add_filter( ‘psm-get-chart-data’, ‘psm_filter_charts_data’, 10, 3 );function psm_filter_charts_series( $series, $chart_id, $type )
{
$series = array(
// the first series
array(
‘label’ => ‘Date’, // the label of the series
‘type’ => ‘date’ // the type of the series
),
// the second series
array(
‘label’ => ‘Index’, // the label of the series
‘type’ => ‘number’ // the type of the series
)
);return $series;
}
add_filter( ‘psm-get-chart-series’, ‘psm_filter_charts_series’, 10, 3 );?>
[visualizer id=”5″ series=”psm-get-chart-series” data=”psm-get-chart-data”]