Skip to content

Instantly share code, notes, and snippets.

@cesswairimu
Created January 14, 2019 10:22
Show Gist options
  • Select an option

  • Save cesswairimu/91b091302ab959c4a4f735e8a03e94c0 to your computer and use it in GitHub Desktop.

Select an option

Save cesswairimu/91b091302ab959c4a4f735e8a03e94c0 to your computer and use it in GitHub Desktop.
// trying to use this function to plot my values
helpful link => https://codepen.io/apexcharts/pen/QrbEQg
function generateDayWiseTimeSeries(s, count) {
var values = [[
<%= @graph_notes.values.collect {|ind| ind[1]} %>,
<%= @graph_wikis.values.collect {|ind| ind[1]} %>,
<%= @graph_comments.values.collect {|ind| ind[1]} %>
]];
var i = 0;
var series = [];
var x = new Date("11 Nov 2012").getTime();
while (i < count) {
series.push([x, values[s][i]]);
x += 86400000;
i++;
}
return series;
//first I want value x to be something like <%= @time %>
//also I cannot get what line 16 is doing.
@Harrisonkamau
Copy link
Copy Markdown

But as long as you're getting it from the Rails (API), you don't have to worry since the API is already validating the type of input

@Harrisonkamau
Copy link
Copy Markdown

Or maybe I'm not really getting you :'(

@cesswairimu
Copy link
Copy Markdown
Author

and then how will js consume it?

@cesswairimu
Copy link
Copy Markdown
Author

waiting for the link

@Harrisonkamau
Copy link
Copy Markdown

@Harrisonkamau
Copy link
Copy Markdown

There you go

@Harrisonkamau
Copy link
Copy Markdown

<script>
console.log('Hello world');
</script>

@Harrisonkamau
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment