Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 自定义highcharts的点弹出窗口_Jquery_Highcharts - Fatal编程技术网

Jquery 自定义highcharts的点弹出窗口

Jquery 自定义highcharts的点弹出窗口,jquery,highcharts,Jquery,Highcharts,在这把小提琴中: 序列标签未正确显示。如果将鼠标悬停在某个数据点上,则x数据点将以毫秒为单位显示为时间 src: <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <div id="chart-grid"><

在这把小提琴中:

序列标签未正确显示。如果将鼠标悬停在某个数据点上,则x数据点将以毫秒为单位显示为时间

src:

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="chart-grid"></div>

.chart {
    width: 350px; 
    height: 300px;
}

var json = [
    {
        "header": "test1",
        "children": [
            {
                "date": "2015-01-02",
                "count": "36"
            },
            {
                "date": "2015-01-03",
                "count": "29"
            }
        ]
    },
    {
        "header": "test2",
        "children": [
            {
                "date": "2015-01-02",
                "count": "36"
            },
            {
                "date": "2015-01-03",
                "count": "129"
            }
        ]
    }
];

$(document).ready(function () {

    var options = {
        chart: {
            type: 'scatter'
        },
        title: {
            text: 'test' // Title for the chart
        },
        subtitle: {},
        legend: {
            enabled: true
        },
        tooltip: {},
        plotOptions: {
            series: {
                //pointStart: pointStart,
                pointInterval: 24 * 3600 * 1000 * 30
            }
        },
        xAxis: {

            type: 'datetime'
        },
        yAxis: {
            minPadding: 0,
            maxPadding: 0,
            gridLineColor: 'rgba(204,204,204,.25)',
            gridLineWidth: 0.5,
            title: {
                text: 'Access Count',
                rotation: 0,
                textAlign: 'right',
                style: {
                    color: 'rgba(0,0,0,.9)',
                }
            },
            labels: {
                style: {
                    color: 'rgba(0,0,0,.9)',
                    fontSize: '9px'
                }
            },
            lineWidth: .5,
            lineColor: 'rgba(0,0,0,.5)',
            tickWidth: .5,
            tickLength: 3,
            tickColor: 'rgba(0,0,0,.75)'
        },
        series:[]
    };

    var $chartGrid = $('#chart-grid'),
        title = [],
        serie,
        date,
        name;

    $.each(json, function(i, item) {
        name = 'container-' + i;
        $chartGrid.append('<div id="'+name+'" class="chart"></div>');   

        serie = [{
            data: []
        }];

        $.each(item.children, function(j, points) {
            date = points.date.split('-'); //Date.parse doens't work in FF and IE

            serie[0].data.push({
                x: Date.UTC(date[0],date[1],date[2]),
                y: parseFloat(points.count)
            });
        });


        options.title.text = item.header;
        options.series = serie;
        $('#' + name).highcharts($.extend({}, options));
    });


});

.图表{
宽度:350px;
高度:300px;
}
var json=[
{
“header”:“test1”,
“儿童”:[
{
“日期”:“2015-01-02”,
“计数”:“36”
},
{
“日期”:“2015-01-03”,
“计数”:“29”
}
]
},
{
“header”:“test2”,
“儿童”:[
{
“日期”:“2015-01-02”,
“计数”:“36”
},
{
“日期”:“2015-01-03”,
“计数”:“129”
}
]
}
];
$(文档).ready(函数(){
变量选项={
图表:{
键入:“散布”
},
标题:{
text:'test'//图表的标题
},
副标题{},
图例:{
已启用:true
},
工具提示:{},
打印选项:{
系列:{
//点开始:点开始,
点间距:24*3600*1000*30
}
},
xAxis:{
键入:“日期时间”
},
亚克斯:{
数字:0,
maxPadding:0,
gridLineColor:'rgba(204204,.25)',
网格线宽度:0.5,
标题:{
文本:“访问计数”,
轮换:0,
textAlign:'右',
风格:{
颜色:“rgba(0,0,0,9)”,
}
},
标签:{
风格:{
颜色:“rgba(0,0,0,9)”,
字体大小:“9px”
}
},
线宽:.5,
线条颜色:“rgba(0,0,0,5)”,
宽度:.5,
长度:3,
tickColor:'rgba(0,0,0,75)'
},
系列:[]
};
var$chartGrid=$(“#图表网格”),
标题=[],
意甲,
日期,
名称
$.each(json,函数(i,项){
名称='容器-'+i;
$chartGrid.append(“”);
系列=[{
数据:[]
}];
$。每个(项。子项,函数(j,点){
date=points.date.split('-');//date.parse在FF和IE中不起作用
serie[0]。data.push({
x:Date.UTC(日期[0],日期[1],日期[2]),
y:parseFloat(points.count)
});
});
options.title.text=item.header;
options.series=系列;
$('#'+name).highcharts($.extend({},options));
});
});
如果使用线图,则显示日期

如何在格式为
dd/mm/yyyy hh:mm:ss
的悬停上显示x轴值


弹出的x和y标签可以重命名吗?

您可以使用工具提示格式化程序选项和Highcharts.dateFormat根据需要进行格式化

tooltip: {
    formatter: function () {
        return 'x: ' + Highcharts.dateFormat('%d/%m/%Y %H:%M:%S', this.x) + '<br>' + 'y: ' + this.y;
    }
},
工具提示:{
格式化程序:函数(){
返回'x:'+Highcharts.dateFormat('%d/%m/%Y%H:%m:%S',this.x)+'
'+'Y:'+this.Y; } },