Home Forums Chart Support xValueType

xValueType

Viewing 4 posts - 1 through 4 (of 4 total)
  • #24110

    Hi, i have a date format like this 2019-01-26 07:25:01 as source and i want to use it in my canvasjs.
    I use mysql too so i can’t really change it.
    Here is my skript if can help:

            <script>
                window.onload = function () {
    
                    var chart = new CanvasJS.Chart("chartContainer", {
                        animationEnabled: true,
                        title:{
                            text: "Utilizzo RAM"
                        },
                        axisY: {
                            title: "Utilizzo RAM in MB",
                            valueFormatString: "#0,,.",
                            suffix: "MB",
                            prefix: ""
                        },
                        data: [{
                            type: "spline",
                            markerSize: 5,
                            xValueFormatString: "YYYY-MM-DD HH:mm:ss",
                            yValueFormatString: "####MB",
                            xValueType: "dataTime",
                            dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
                        }]
                    });
    
                    chart.render();
    
                }
            </script>

    But, when i put it in my page, in the console i get this error:

    
    canvasjs.min.js:209 Uncaught TypeError: Cannot read property 'getTime' of null
        at l._processMultiseriesPlotUnit (canvasjs.min.js:209)
        at l._processData (canvasjs.min.js:206)
        at l.setLayout (canvasjs.min.js:189)
        at l.render (canvasjs.min.js:201)
        at window.onload (status.php:30)
    l._processMultiseriesPlotUnit	@	canvasjs.min.js:209
    l._processData	@	canvasjs.min.js:206
    l.setLayout	@	canvasjs.min.js:189
    l.render	@	canvasjs.min.js:201
    window.onload	@	status.php:30
    load (async)		
    (anonymous)	@	status.php:8

    Then, i can see only a white space where there should be the canvas, but empty.
    Somebody can help me?
    Thanks advice!

    • This topic was modified 5 years, 10 months ago by GABRYCA.
    • This topic was modified 5 years, 10 months ago by GABRYCA.
    #24127

    @gabryca,

    There is a typo in your code xValueType: "dataTime",. Please change dataTime to dateTime and it should work fine. You can also refer to this documentation page for more information.

    In case it doesn’t help you out, can you please create a sample project with a sample database and share it over Google-Drive or Onedrive so that we can look into your code understand it better and help you out?

    ___________
    Indranil Deo,
    Team CanvasJS

    #24137
    #24152

    @gabryca,

    Glad that you figured out a way to make it work :)

    ___________
    Indranil Deo,
    Team CanvasJS

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

You must be logged in to reply to this topic.