Home Forums Chart Support problem with showing time in Y axis

problem with showing time in Y axis

Viewing 2 posts - 1 through 2 (of 2 total)
  • #22948

    I made a chart that shows machines and the times that was taken for them to be fixed (machines X, time Y)
    the data is loaded dynamically via mysql like the following
    <?php
    include_once(“connexion.php”);
    ini_set(‘max_execution_time’,300);
    //ini_set(‘error_reporting’, E_ALL);

    $sq = “select machine,date_tech,time(time_fin – time_deb) as diff from action_archiv_tech WHERE (date_tech BETWEEN ‘2018-09-10’ AND ‘2018-10-06’)”;
    $r = mysql_query($sq) or (die(mysql_error()));
    while($tab = mysql_fetch_assoc($r)) {
    $machine = $tab[‘machine’];
    $diff = $tab[‘diff’];
    // $data[] = [“label”=>$machine, “y”=>$diff];
    $data[] = array(
    ‘label’ => $tab[‘machine’],
    ‘y’ => $tab[‘diff’]
    );
    }

    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset=”UTF-8”>
    <script>

    window.onload = function () {

    var chart = new CanvasJS.Chart(“chartContainer”, {
    theme:”light2″,
    animationEnabled: true,
    title:{
    text: “PM”
    },
    axisY :{
    includeZero: false,
    title: “Heures”,
    suffix: “H”
    },
    toolTip: {
    shared: “true”
    },
    legend:{
    cursor:”pointer”,
    itemclick : toggleDataSeries
    },
    data: [
    {
    type: “spline”,
    showInLegend: true,
    yValueFormatString: “##.00H”,
    name: “Curative”,
    dataPoints: <?php echo json_encode($data); ?>
    }

    ]
    });
    chart.render();

    function toggleDataSeries(e) {
    if (typeof(e.dataSeries.visible) === “undefined” || e.dataSeries.visible ){
    e.dataSeries.visible = false;
    } else {
    e.dataSeries.visible = true;
    }
    chart.render();
    }

    }
    </script>
    </head>
    <body>
    <div id=”chartContainer” style=”height: 370px; max-width: 1920px; margin: 0px auto;”></div>
    <script src=”../../canvasjs.min.js”></script>
    </body>
    </html>

    However the results are not like the expected

    results : https://i.stack.imgur.com/zyIZM.png

    Could you please help me figure out how to solve this problem :)

    #22952

    @yawness,

    Can you please share a sample project along with sample database over google-drive or one-drive reproducing the issue you are facing, so that we can look into your code, understand the scenario better and help you out?

    __
    Priyanka M S
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.