HighCharts - creating scatter with date

I want to create a scater with datetime as xAxis, I succeeded but x-interval with days, I have a hard time doing this when x-interval is with minutes.

My JS:

function startDashboard3DScatter() {
    $.getJSON('/Handlers/MainHandler.ashx?op=getNetwork', function (data) {
        Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function (color) {
            return {
                radialGradient: {
                    cx: 0.4,
                    cy: 0.3,
                    r: 0.5
                },
                stops: [
                    [0, color],
                    [1, Highcharts.Color(color).brighten(-0.2).get('rgb')]
                ]
            };
        });
        // Set up the chart
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'networkAlerts',
                margin: 100,
                type: 'scatter',
                width: 600,
                height: 300,
                options3d: {
                    enabled: true,
                    alpha: 10,
                    beta: 30,
                    depth: 250,
                    viewDistance: 5,

                    frame: {
                        bottom: { size: 1, color: 'rgba(0,0,0,0.02)' },
                        back: { size: 1, color: 'rgba(0,0,0,0.04)' },
                        side: { size: 1, color: 'rgba(0,0,0,0.06)' }
                    }
                }
            },
            title: {
                text: 'Network'
            },
            plotOptions: {
                scatter: {
                    width: 100,
                    height: 100,
                    depth: 20
                },
                series: {
                    marker: {
                        lineWidth: 1
                    }
                }
            },
            yAxis: {
                min: 0,
                title: { text: 'Risk Score' }
            },
            xAxis: {
                min: 0,
                max: 6,
                gridLineWidth: 1,
                title: { text: 'Time line' },
                labels: {
                    formatter: function () {
                        var date = new Date();
                        date.setDate(date.getDate() - this.value);
                        return date.toDateFormat();// this.value + ' %';
                    }
                }
            },
            zAxis: {
                min: 0,
                max: 10
            },
            legend: {
                enabled: false
            },
            series: data
        });
    });
};

      

My response from request get =

data = 
[ 
    {"name":"name1", "id":"D/1", "color": "#55BF3B", "data": [[6, 100]]},
    {"name":"name2", "id":"D/5", "color": "#55BF3B", "data": [[3, 1]]}
]

      

Data for ['days before today, yValue']

So I did this when I post days to today and I format xAxis, the problem I said is that the points are in 1day interval and I want to do it 1 minute or 1 hour interval.

Any ideas, I've been stuck on this for days.

+3


source to share


1 answer


It's good that the solution was not very heavy:

Changed:



labels: {
    formatter: function () { 
        var date = new Date(new Date().getTime() - (this.value * 60 * 60 * 1000));
        return date.toDateFormat();
    }
}

      

And in the server code, it returns hours instead of days and it works.

+2


source







All Articles