0

I am trying to use Flot tooltip in a coffee file, but I am having trouble inserting the necessary labelled javascript/json code into the coffee code. I've tried the js2coffee converter tool, but it doesn't seem to work. Here's the code, I am trying to translate into coffee; any suggestions?

grid:  { hoverable: true }, 
  tooltip: {
    show: true,
    content: "y: %y"
  }
gwydion93
  • 1,681
  • 3
  • 28
  • 59
  • 2
    In what way does that not work? And what does the code around it look like? The stuff you posted is fine if it's part of a larger object initializer, but by itself it's meaningless. – Pointy Jul 11 '16 at 15:01
  • I think I have figured this out, even though it is not quite working. Basically, I wanted to know what the above code would look like in coffeescript. As you can see the above is in a json-type format that works fine in javascript, but will not work in coffeescript. I believe the above should look like this `grid: clickable: true hoverable: true color: "white" tooltip: show: true content: "Y: %y"` – gwydion93 Jul 11 '16 at 16:25
  • Braces are (sometimes) optional in CoffeeScript but you can leave them in if they make the structure clearer. Be very consistent with your indentation and include braces, brackets, and parentheses as needed to clarify the structure. – mu is too short Jul 11 '16 at 17:04

1 Answers1

0

The object can be written in CoffeeScript as follows:

somevar =
  grid:
    hoverable: true
  tooltip:
    show: true
    content: 'y: %y'

You can see the conversion to JavaScript live on coffeescript.org

Ilya Vassilevsky
  • 981
  • 6
  • 14