C
C
Chronic 862016-05-17 07:17:13
Ruby on Rails
Chronic 86, 2016-05-17 07:17:13

How to display highcharts correctly?

There is a schedule

@line = LazyHighCharts::HighChart.new('graph1') do |f|
        f.title(text: "Динамика задолженности")
        f.subtitle(text: 'Динамика задолжености')
        f.xAxis(categories: @period)
        f.series(:name=>'Поставщик 1', :data=> @line_com1)
        f.series(:name=>'Поставщик 2', :data=> @line_com2 )
        f.series(:name=>'Поставщик 3', :data=> @line_com3)
        f.series(:name=>'Поставщик 4', :data=> @line_com4)
  
        f.yAxis [
          {title: {text: "Уровень задолженности", margin: 70} },
          {title: {text: ""}, opposite: true},
        ]

        f.legend(align: 'right', verticalAlign: 'top', y: 75, x: -50, layout: 'vertical')
        f.chart({defaultSeriesType: "line"})

This chart works, but there is a problem, the number of suppliers can change, and manually add a line like
f.series(:name=>'Поставщик 2', :data=> @line_com2 )

not very cool.
So the question arose, is it possible to pull out the number of suppliers somehow dynamically from the database and generate the required number of f.series?
Something like this:
f.series(:name=> @company, :data=> @data )
@company = ['Vendor 1', 'Vendor 2',....'Vendor N']
@data =

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question