'use strict'

module.exports = createSpikeOptions

var str2RGBArray = require('../lib/str2rgbarray');

var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']

function SpikeOptions() {
    this.enable = [true, true, true];
    this.colors = [[0,0,0,1],
                   [0,0,0,1],
                   [0,0,0,1]];
    this.sides = [true, true, true];
    this.lineWidth = [1,1,1];
}

var proto = SpikeOptions.prototype

proto.merge = function(sceneLayout) {
    var opts = this;
    for (var i = 0; i < 3; ++i) {
        var axes = sceneLayout[AXES_NAMES[i]];

        if(axes.showspikes) {
          this.enable[i] = true;
          this.colors[i] = str2RGBArray(axes.spikecolor);
          this.sides[i] = axes.spikesides;
          this.lineWidth[i] = axes.spikethickness;
        } else {
          this.enable[i] = false;
        }
    }
}

function createSpikeOptions(layout) {
    var result = new SpikeOptions()
    result.merge(layout)
    return result
}

@@ -183,16 +183,17 @@
 s.enable
+d
  = %5Btrue
@@ -303,25 +303,29 @@
 %5D;%0A    this.
-s
+drawS
 ides = %5Btrue
@@ -554,37 +554,8 @@
 ;%0A%0A 
-       if(axes.showspikes) %7B%0A
     
@@ -551,33 +551,32 @@
 i%5D%5D;%0A%0A          
- 
 this.enable%5Bi%5D =
@@ -574,18 +574,30 @@
 able
+d
 %5Bi%5D = 
-true
+axes.showspikes
 ;%0A  
@@ -667,17 +667,21 @@
    this.
-s
+drawS
 ides%5Bi%5D 
@@ -754,69 +754,8 @@
 ss;%0A
-        %7D else %7B%0A          this.enable%5Bi%5D = false;%0A        %7D%0A
     

fix Mikola -> plotly API conversion for spikes