为每个新页面创建一个新图表

时间:2018-03-19 09:14:22

标签: javascript json highcharts

我有一个JSON(SurveyJS),其中包含来自用户的回复:

var surveyJSON = {pages:[{name:"page1",elements:[{type:"rating",name:"How confident are you conducting market analysis?",description:"5 - most confident"},{type:"rating",name:"How confident are you evaluating the feasibility of a new opportunity?",description:"5 - most confident"},{type:"rating",name:"How confident are you discovering new ways to improve existing products?",description:"5 - most confident"}]},{name:"page2",elements:[{type:"rating",name:"How confident are you targeting new markets and customers?",description:"5 - most confident",isRequired:true},{type:"rating",name:"How confident are you reacting quickly to take advantage of business opportunities?",description:"5 - most confident",isRequired:true},{type:"rating",name:"How confident are you creating new products and services and/or developing new ideas?",description:"5 - most confident"}]}]}

我正在尝试使用我的HighChart为每个新的回复页生成一个新图表。因此,第1页有图表1,第2页有图2等... 抓到了吗?我不一定知道JSON有多少页面。

我将如何得到这样的东西?

我当前的HighCharts代码,它接受所有响应(不是我想要的):

    Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Your confidence levels'
    },
    xAxis: {
      categories: titleArray,
    },
    yAxis: {
        title: {
            text: 'Your confidence levels',
            align: 'high'
        }
    },
    series: [{
        data: valuesArray
    }]
    });

1 个答案:

答案 0 :(得分:0)

为什么不能获得surveyJSON.pages.length或者如果您有权访问您的surveyjs模型,您可以获得survey.pages.length