Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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
Ruby on rails 4 使用表中的数据创建highcharts_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 4 使用表中的数据创建highcharts

Ruby on rails 4 使用表中的数据创建highcharts,ruby-on-rails-4,Ruby On Rails 4,我正在尝试使用表中的数据在rails中使用高图创建条形图。我有一个名为school的表,它包含两列,即姓名和出勤率。我想在x轴上显示学生姓名,在y轴上显示出勤率。我的JavaScript代码是: $(function () { // Create the chart $('#student')high-charts({ chart: { type: 'column' }, title: {

我正在尝试使用表中的数据在rails中使用高图创建条形图。我有一个名为school的表,它包含两列,即姓名和出勤率。我想在x轴上显示学生姓名,在y轴上显示出勤率。我的JavaScript代码是:

$(function () {
    // Create the chart
    $('#student')high-charts({
       chart: {
            type: 'column'
         },
        title: {
           text: 'student details'
       },
        x Axis: {
        type: 'category'
         },
        y Axis: {
           title: {
              text: 'Total attendance'
          }

    },
    legend: {
        enabled: false
    },
    plot-options: {
        series: {
            border-width: 0,
            data-labels: {
                enabled: true,
                format: '{point.y:.1f}%'
            }
        }
    },

    tool-tip: {
        header-format: '<span style="font-size:11px">{series.name}</span>     <Br>',
        point-format: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<BR/>'
    },
series: [ {
            name: 'Stu',
            id: 'Stu',
            data: [
                [<%= @students.each do |s|%>
                   '<%= s.name %>',
                    <%= s.attendance%>
                 <%end%>

                ]

            ]
        }
$(函数(){
//创建图表
$(“#学生”)高图表({
图表:{
类型:“列”
},
标题:{
文本:“学生详细信息”
},
x轴:{
类型:“类别”
},
y轴:{
标题:{
正文:“总出席人数”
}
},
图例:{
已启用:false
},
打印选项:{
系列:{
边框宽度:0,
数据标签:{
启用:对,
格式:“{point.y:.1f}%”
}
}
},
工具提示:{
标题格式:“{series.name}
”, 点格式:'{point.name}:{point.y:.2f}占总数的% }, 系列:[{ 姓名:“斯图”, id:'斯图', 数据:[ [ '', ] ] }
在我的HTML中,我有:

<div class="col-md-8">
   <div class="x_panel">
        <div id="student" style="min-width: 310px; height: 400px; margin: 0 auto">
        </div>
  </div>
 </div>

我无法加载条形图。请帮助尝试此操作

$(function () {
// Create the chart

new Highcharts.Chart({
chart: { renderTo: 'student' },
    title: {
       text: 'student details'
   },
    x Axis: {
    type: 'category'
     },
    y Axis: {
       title: {
          text: 'Total attendance'
      }

},
legend: {
    enabled: false
},
plot-options: {
    series: {
        border-width: 0,
        data-labels: {
            enabled: true,
            format: '{point.y:.1f}%'
        }
    }
},

tool-tip: {
    header-format: '<span style="font-size:11px">{series.name}</span>     <

Br>',
        point-format: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<BR/>'
    },
series: [ {
            name: 'Stu',
            id: 'Stu',
            data: [
                [<%= @students.each do |s|%>
                   '<%= s.name %>',
                    <%= s.attendance%>
                 <%end%>

                ]

            ]
        }
$(函数(){
//创建图表
新海图,海图({
图表:{renderTo:'student'},
标题:{
文本:“学生详细信息”
},
x轴:{
类型:“类别”
},
y轴:{
标题:{
正文:“总出席人数”
}
},
图例:{
已启用:false
},
打印选项:{
系列:{
边框宽度:0,
数据标签:{
启用:对,
格式:“{point.y:.1f}%”
}
}
},
工具提示:{
标题格式:'{series.name}<
Br>',
点格式:'{point.name}:{point.y:.2f}占总数的%
},
系列:[{
姓名:“斯图”,
id:'斯图',
数据:[
[
'',
]
]
}
创建一个新的highchart并在图表中呈现div

$(function () {
// Create the chart

new Highcharts.Chart({
chart: { renderTo: 'student' },
    title: {
       text: 'student details'
   },
    x Axis: {
    type: 'category'
     },
    y Axis: {
       title: {
          text: 'Total attendance'
      }

},
legend: {
    enabled: false
},
plot-options: {
    series: {
        border-width: 0,
        data-labels: {
            enabled: true,
            format: '{point.y:.1f}%'
        }
    }
},

tool-tip: {
    header-format: '<span style="font-size:11px">{series.name}</span>     <

Br>',
        point-format: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<BR/>'
    },
series: [ {
            name: 'Stu',
            id: 'Stu',
            data: [
                [<%= @students.each do |s|%>
                   '<%= s.name %>',
                    <%= s.attendance%>
                 <%end%>

                ]

            ]
        }
$(函数(){
//创建图表
新海图,海图({
图表:{renderTo:'student'},
标题:{
文本:“学生详细信息”
},
x轴:{
类型:“类别”
},
y轴:{
标题:{
正文:“总出席人数”
}
},
图例:{
已启用:false
},
打印选项:{
系列:{
边框宽度:0,
数据标签:{
启用:对,
格式:“{point.y:.1f}%”
}
}
},
工具提示:{
标题格式:'{series.name}<
Br>',
点格式:'{point.name}:{point.y:.2f}占总数的%
},
系列:[{
姓名:“斯图”,
id:'斯图',
数据:[
[
'',
]
]
}

创建新的highchart并在图表中渲染div

是否将highchart文件添加到js文件夹并在head中调用?是否添加了此项?是否将highchart文件添加到js文件夹并在head中调用?是否添加了此项?