Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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
Javascript HighCharts-动态图形&右侧双轴上无刻度线_Javascript_Jquery_Highcharts - Fatal编程技术网

Javascript HighCharts-动态图形&右侧双轴上无刻度线

Javascript HighCharts-动态图形&右侧双轴上无刻度线,javascript,jquery,highcharts,Javascript,Jquery,Highcharts,我是个新手 我正在动态地在getData函数中调用2个ajax调用,并用2个y轴绘制2个系列的high图表 每个ajax调用都返回json数据 第一个json数据示例 [{dt:2000年5月15日,索引:2007.030850},{dt:2000年5月16日,索引:2025.956108}] 第二个json数据示例 [{dt:2000年5月15日,资产净值:145.236000},{dt:2000年5月16日,资产净值:146.602974}] 我正在创建两个带有2个ajax调用的系列。在第二

我是个新手

我正在动态地在getData函数中调用2个ajax调用,并用2个y轴绘制2个系列的high图表

每个ajax调用都返回json数据

第一个json数据示例 [{dt:2000年5月15日,索引:2007.030850},{dt:2000年5月16日,索引:2025.956108}]

第二个json数据示例 [{dt:2000年5月15日,资产净值:145.236000},{dt:2000年5月16日,资产净值:146.602974}]

我正在创建两个带有2个ajax调用的系列。在第二个ajax调用中,我为第二个系列数据动态添加了一个y轴

$(document).ready(function() {
        function getData() {

            var chart = Highcharts.charts[0];
/* 1st Ajax Call to get the json data to plot the first series */
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/Six/TSServlet?file=ivv-sixIshareFundsHistoryIndex.json',
                data: '',
                async: false,
                success: function(data) {
                    var categories1 = [];
                    var seriesData1 = [];
                    var yaxis;
                    $.each(data, function(i, e) {
                        categories1.push(e.dt);
                        /* below step to remove , is not important, done for my program */
                        yaxis = parseFloat(e.index.replace(/,/g, '')); 
                        seriesData1.push(yaxis);
                    })
// add x-axis catagories
                    chart.xAxis[0].update({
                        categories: categories1,
                        tickInterval: 150
                    }, true);

    // add the 1st series
                    chart.series[0].setData(seriesData1);
                }
            });
               /* 2nd Ajax Call to get the json data to plot the second series */
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/Six/TSServlet?file=ivv-sixIshareFundsHistoryNav.json',
                data: '',
                async: false,
                success: function(data) {
                    var categories2 = [];
                    var seriesData2 = [];
                    var yaxis;
                    $.each(data, function(i, e) {
                        categories2.push(e.dt);
                        /* below step to remove , is not important, done for my program */

                        yaxis = parseFloat(e.nav.replace(/,/g, ''));
                        seriesData2.push(yaxis);
                    })
/*这就是问题所在,为第2个系列动态添加双y轴*/

                     chart.addAxis({ // Secondary yAxis
                        id: 'NAV-Series-Axis',
                        title: {
                            text: 'NAV Series'
                        },
                        lineWidth: 2,
                        lineColor: '#08F',
                        opposite: true
                    });
//添加第2个系列 chart.addSeries{name:NAV Series,yAxis:'NAV Series Axis',data:seriesData2}

                }
            });
        }  //getdata function ends here .............

        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        var chart;

        $('#container').highcharts({
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                renderTo: 'container',
                events: {
                    load: function() {
                        var series = this.series[0];
                        getData();
                    }
                }
            },
            title: {
                text: 'Six Share Funds History'
            },
            labels: {
                formatter: function() {
                    return this.value + ' %';
                }
            },
            xAxis: {
                tickLength: 10
            },
            tooltip: {
                formatter: function() {
                    return '<b>' + this.series.name + '</b><br/>' + this.x + '<br/>' + Highcharts.numberFormat(this.y, 2);
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [{
                "Name": []
            }]
        });
    });
});
我的问题是我得到了2个系列图的2个轴,但在右边的y轴上没有记号。如何解决这个问题?理想情况下,我应该在右边的蓝色条上看到100个记号,200个记号等等,就像左边的y轴有5001000个记号一样

请看屏幕截图,我看不到第二系列图表右侧蓝色条上的记号

编辑以添加jsp:

<div id='TimeSeriesId'>
        <div id="container" style="width: 100%; height: 600px;"></div>
    </div>

只需将yAxis设置为包含多个元素的数组,即可添加多个Y轴。每个轴都可以具有所有常用的轴属性,请参见


要动态添加它们,请使用chart.yAxis=新数组;chart.yAxis[1]。title=。。。等等。

我看不出您在DIV中定义图表宽度的位置。我猜刻度线就在屏幕外。如果将图表的宽度设置为小于容器DIV,会发生什么情况?那么它能表现出来吗?@wergeld你太棒了。谢谢你给我指引了正确的方向。正如您所指出的,我已经检查了IE的开发工具,发现它正在绘制,但记号刚好从屏幕上消失。从我的javascript代码中删除marginRight:10之后,它工作得很好。
    yAxis: [{ // Primary yAxis
        labels: { ...
        },
        title: { ...
        },
        opposite: true
    }, { // Secondary yAxis
        title: { ...
        },
        labels: { ...
        }
    }, { // Tertiary yAxis
        title: { ...
        },
        labels: { ...
        },
        opposite: true
    }],
    ...