Home forums Chart Support show one value in chart but another in X axis


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

    Hi all,
    When I move the mouse over the point it shows the wrong date In the picture Im over 12-jun but it says 11-jun.. happens the same in every point.

    The value “32” is OK, the date is not ok..

    but if i show the series in separated charts the data is ok.


    $.getJSON("dataNro7.php", function (result) {
                var dps1 = [], dps2 = [];
            for(var i = 0; i < result.length; i++) {
                switch(result[i].palabra) {
                case 'pa': dps1.push({ x:  new Date (result[i].label), y: result[i].y });
                case 'ma': dps2.push({ x:  new Date(result[i].label), y: result[i].y });
                    var revenueBarChart = new CanvasJS.Chart("Historiales2y3", {
                        animationEnabled: false,
                        backgroundColor: "transparent",
                        theme: "theme2",
                                interval: 2,
                                valueFormatString: "DD-MMM" ,
                                gridThickness: 0,
                                labelFontSize: 12,
                                labelMaxWidth: 100,
                                labelAngle: 0,
                                culture: "es",
                                labelFontStyle: "normal",
                                labelFontWeight: "normal",
                                labelFontFamily: "Lucida Sans Unicode"
                                labelFontSize: 12,
                                interlacedColor: "rgba(1,77,101,.05)",
                                gridColor: "rgba(1,77,101,.1)"
                        data: [   { type: "splineArea",
                                    showInLegend: true,
                                    name: "PA",
                                    color: "rgba(12,143,221,.8)",
                                    axisYType: "secondary",
                                     dataPoints: dps1 },
                                { type: "splineArea",
                                    showInLegend: true,
                                    name: "MA",
                                    color: "rgba(192,143,121,.8)",
                                    axisYType: "secondary",
                                     dataPoints: dps2 } ]


    As documented in MDN,
    Given a date string of “March 7, 2014”, parse() assumes a local time zone, but given an ISO format such as “2014-03-07” it will assume a time zone of UTC (ES5 and ECMAScript 2015). Therefore Date objects produced using those strings may represent different moments in time depending on the version of ECMAScript supported unless the system is set with a local time zone of UTC. This means that two date strings that appear equivalent may result in two different values depending on the format of the string that is being converted.

    Please check this stackoverflow thread for more info. You can solve it either as mentioned in stackoverflow or by changing the date-format as shown in this jsfiddle.

    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.