Search code examples
zingchart

ZingChart Y Axis Label Formatting


Is it possible in ZingChart to add a secondary y scale that uses the same values as the primary y scale, but just uses a simple conversion (e.g., anomaly degrees Celsius*1.8 = anomaly degrees Fahrenheit).

something like:

var chartConfig = {
  scaleY2: { format: %v*1.8 }
}

Or, perhaps a function, like:

var chartConfig = {
  scaleY2: { format: 'formatAxis()' }
}
...
formatAxis = function(p){ return { format:p.value*1.8 } }

I'm plotting temperature anomalies in degrees C on the primary y-axis. I'd like the degrees F to show up on the secondary y-axis.


Solution

  • You do indeed use a function. I just had a syntax error.

    var chartConfig = {
      scaleY2: { format: 'formatAxis()' }
    }
    ...
    window.formatAxis = function(v){
      return (v*1.8).toFixed(2)+'\u00B0F';
    }