weixin_33694620 2018-03-01 00:53 采纳率: 0%
浏览 40

Morris.js图表​​设计修复

I have a problem I am able to change my Morris.js Chart to bar graph to line graph the problem is the design of the line graph. Please refer to the two (2) screen shots to see what I meant. When I switch the graph into a line graph the graphical representation of data is messed up. How can I fix this?

Bar Graph Line Graph

PHP Code I used :

$sql = "SELECT MONTHNAME(date) AS date, SUM(sales) AS sales FROM tblSales WHERE YEAR(date)=YEAR(now()) GROUP BY MONTHNAME(date)";
$result = mysqli_query($conn, $sql);

while ($row = mysqli_fetch_array($result)) {
    $ar[] = array(
        'month' => $row['date'],
        'sales' => $row['sales']
    );
}
ob_clean();
echo json_encode($ar);

AJAX Code I used :

var statement = 1;
    $.ajax ({
        url:"show_total_overall_sales.php",
        data: "statement="+statement,
        method: "POST",
        success: function(branch_data){
            new Morris.Line({
                element: 'total-sales',
                data: JSON.parse(branch_data),
                xkey: 'daily',
                ykeys: ['sales'],
                labels: ['Total Sales'],
                hideHover: 'auto'
            });
        }
    });
  • 写回答

1条回答 默认 最新

  • DragonWar% 2018-03-01 07:19
    关注

    Maybe you can try to use parseTime:false

    评论

报告相同问题?