Forum Stats

  • 3,768,721 Users
  • 2,252,841 Discussions
  • 7,874,694 Comments

Discussions

Enabling y2axis for ojchart

3070722
3070722 Member Posts: 10
edited Nov 12, 2015 9:01PM in Oracle JET

I'm not able to enable the y2 axis for the ojchart component.  No second y axis is rendered when I try to enable the y2 axis.  Here is a sample of the code I'm using to enable the y2 axis:


<div data-bind="ojComponent: {

     component: 'ojChart',

     y2Axis: {
       rendered: 'on',
       axisLine: {

          rendered: 'on'

      },

     }

}">


Is there something I'm doing wrong or I'm missing?


Thank you.

Answers

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited Nov 12, 2015 6:47PM
  • Hugh Zhang-Oracle
    Hugh Zhang-Oracle Member Posts: 193 Employee
    edited Nov 12, 2015 7:42PM

    Hi,

    By default, the y2 axis will be rendered whenever a y2 series is present in the data. To specify a series as corresponding to the y2 axis, set assignedToY2 to "on" on the series object. For example, the second series in the following snippet is assigned to the y2 axis.

          <div data-bind="ojComponent: {

               component: 'ojChart',

               series: [{name: 'y1Series', items: [1,2,3]},

                            {name: 'y2Series', assignedToY2: 'on', items: [10,20,30]}]

          }" style="width:400px; height:300px;">

        </div>

    The y2Axis attributes are only needed if you want to customize or hide the y2 axis, gridlines, labels, or title.

    One additional tip is that charts with y2 axes can be harder for the user to understand, so you could consider using our split dual-y feature. It's enabled by setting splitDualY to "on", and you can try it out in the link that Ruben posted above.

    Hope this helps,

    Hugh