Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谁能帮我看一下PHP图表吗?_Php_Mysql_Open Flash Chart - Fatal编程技术网

谁能帮我看一下PHP图表吗?

谁能帮我看一下PHP图表吗?,php,mysql,open-flash-chart,Php,Mysql,Open Flash Chart,我正在尝试显示本月每天的总订单量 $sql = "SELECT date(order_placed_date), COUNT(order_id), SUM(order_total) AS order_total FROM orders WHERE order_placed_date>=date_sub(current_date, INTERVAL 31 DAY) GROUP

我正在尝试显示本月每天的总订单量

$sql = "SELECT date(order_placed_date), 
               COUNT(order_id), 
               SUM(order_total) AS order_total 
        FROM orders 
        WHERE order_placed_date>=date_sub(current_date, INTERVAL 31 DAY) 
        GROUP BY date(order_placed_date)";

if (!$sql) die('Invalid query: ' . mysql_error());

$result = mysql_query($sql);
$data = array();
while($row = mysql_fetch_array($result))
{
  $data[] = intval($row['order_total']);
}

/*
 *  Create a title object and set the text to present month.
 */
$title = new title('Monthly Sales Statistics for '.date("F Y").' (US Dollar)');
$title->set_style( "{font-size: 18px; 
                     font-family: Calibri; 
                     color: #808000; 
                     text-align: center;}" );

//Make our Bar Chart
$bar = new bar_filled('#f99bd6', '#ee0099');
$bar->set_values($data);

//Create a new Chart object
$chart = new open_flash_chart();

// add the title to the chart:
$chart->set_title( $title );
$chart->set_bg_colour("#FFFFFF");

// Display the bar object on the chart
$chart->add_element($bar);

// create an X Axis object
$x = new x_axis();

// grid line and tick every 10
$x->set_range(
    mktime(0, 0, 0, 7, 1, date('Y')),    // <-- min == 1st Jan, this year
    mktime(0, 0, 0, 7, 31, date('Y'))    // <-- max == 31st Jan, this year
    );

// show ticks and grid lines for every day:
$x->set_steps(86400);

$labels = new x_axis_labels();

// tell the labels to render the number as a date:
$labels->text('#date:j #');

// generate labels for every day
$labels->set_steps(86400);

// only display every other label (every other day)
$labels->visible_steps(1);

// finally attach the label definition to the x axis
$x->set_labels($labels);


//Create a Y Axis object
$y_axis = new y_axis();
$y_axis->set_range(1, 15000, 1000);

//Add the y-axis object to the chart
$chart->add_y_axis($y_axis);
$chart->set_x_axis( $x );
echo $chart->toPrettyString();
?>
我更改了while循环:

for( $i=1; $i<32; $i++ )
{
    $row = mysql_fetch_array($result);    
    $data[] = intval($row['order_total']);
}

for($i=1;$i问题是,正如我所说,您有31个数据元素(每天一个),但这段代码在这31天中每2678400秒创建一个x轴元素:

// grid line and tick every 10
$x->set_range(
    mktime(0, 0, 0, 7, 1, date('Y')),    // <-- min == 1st
Jan, this year
    mktime(0, 0, 0, 7, 31, date('Y'))    // <-- max == 31st
Jan, this year
    );

// show ticks and grid lines for every day: 
$x->set_steps(86400);
//网格线并每隔10点打勾
$x->设置范围(
mktime(0,0,0,7,1,日期('Y'),//从数组中设置标签($array\u of_labels);


有一个问题。

你能发布JSON输出的样子吗?乍一看,你的问题和你原来的问题一样:每当我按Enter键时,图像链接就会变成hXXp://这很烦人。
// grid line and tick every 10
$x->set_range(
    mktime(0, 0, 0, 7, 1, date('Y')),    // <-- min == 1st
Jan, this year
    mktime(0, 0, 0, 7, 31, date('Y'))    // <-- max == 31st
Jan, this year
    );

// show ticks and grid lines for every day: 
$x->set_steps(86400);