Nate
Nate

Reputation: 28384

How to display points by day and not time?

I'm trying to use Highstock and am having a problem. When I have multiple series' on the chart, I want the points from the same day to match up, but currently they don't because Highstock takes the time into account.

Here is an example chart:

        $('#chart').highcharts('StockChart', {
            plotOptions: {
                series: {
                    animation: {
                        duration: 0
                    }
                }
            },
            yAxis: {
                labels: {
                    align: 'right',
                    x: -4,
                    formatter: function() {
                        return '$' + Math.round(this.value);
                    },
                },
                tickPixelInterval: 40
            },
            series : [
            {
              "name": "Series 1",
              "data": [
                [
                  1389486123000,
                  200
                ],
                [
                  1389578849000,
                  200
                ]
              ],
              "tooltip": {
                "valueDecimals": 2,
                "valuePrefix": "$"
              }
            },
            {
              "name": "Series 2",
              "data": [
                [
                  1389486240000,
                  100
                ],
                [
                  1389578849000,
                  100
                ]
              ],
              "tooltip": {
                "valueDecimals": 2,
                "valuePrefix": "$"
              }
            }
            ]
        });

JSFiddle: http://jsfiddle.net/EdvVW/

As you can see in JSFiddle, the second two points match up (and when you hover your mouse over them, they both show up in the tooltip, which is what I'm wanting), but even though the first two points are from the same day they don't match up because their timestamps are different.

Is there any way to decrease the accuracy of the rendered points so that data points from the same day match up regardless of time?

Upvotes: 0

Views: 128

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

No, it's not possible. You need to have the same timestamp to match points.

You can preprocess your data: go over all points, create date from timestamp, then use Date.UTC(year, month, day); as x-value for a point.

Upvotes: 2

Related Questions