javascript - How to place labels on opposite Y axis in Highchart without a second series -
i have following chart set in highcharts:
// initialize chart when document loads. $(document).ready(function() { $('#results').highcharts({ chart: { type: 'bar' }, title: { text: '' }, xaxis: [{ categories: [ 'injustice: gods among ★', 'tekken tag tournament 2 ★', 'super smash bros. melee ★', 'persona 4 arena', 'king of fighters xiii', 'dead or alive 5 ultimate', 'street fighter x tekken ver. 2013', 'soulcalibur v' ], }], yaxis: { allowdecimals: false, title: { text: 'votes' } }, series: [{ data: [ {y:1426,color:'#29a329'},{y:823,color:'#29a329'}, {y:462,color:'#29a329'},{y:305,color:'#cc0000'}, {y:181,color:'#cc0000'},{y:148,color:'#cc0000'}, {y:127,color:'#cc0000'},{y:115,color:'#cc0000'} ], datalabels: { color: '#ffffff', enabled: true, inside: true }, showinlegend: false, name: 'votes' }] }); });
this produces chart looks this:
what i'd have labels on y axis on opposite side (it's string, nothing special).
i can add series empty data points, , labels want (i'm writing javascript page server side effect) following code additions:
// initialize chart when document loads. $(document).ready(function () { $('#results').highcharts({ chart: { type: 'bar' }, title: { text: '' }, xaxis: [{ categories: [ 'injustice: gods among ★', 'tekken tag tournament 2 ★', 'super smash bros. melee ★', 'persona 4 arena', 'king of fighters xiii', 'dead or alive 5 ultimate', 'street fighter x tekken ver. 2013', 'soulcalibur v' ], }, { categories: [ '8/5/2013 8:59 pm', '8/5/2013 12:59 pm', '8/5/2013 2:59 pm', '8/5/2013 6:59 pm', '8/5/2013 12:59 am', '8/5/2013 3:59 pm', '8/5/2013 8:23 pm', '8/5/2013 8:19 pm'], opposite: true, title: { text: 'last vote cast at' } }], yaxis: { allowdecimals: false, title: { text: 'votes' } }, series: [{ data: [{ y: 1426, color: '#29a329' }, { y: 823, color: '#29a329' }, { y: 462, color: '#29a329' }, { y: 305, color: '#cc0000' }, { y: 181, color: '#cc0000' }, { y: 148, color: '#cc0000' }, { y: 127, color: '#cc0000' }, { y: 115, color: '#cc0000' }], datalabels: { color: '#ffffff', enabled: true, inside: true }, showinlegend: false, name: 'votes', xaxis: 1 }, { data: [0, 0, 0, 0, 0, 0, 0, 0], showinlegend: false }] }); });
this gets me exactly want, except 1 thing, bars thinner, space made accommodate fake data series isn't meant shown:
the question is, how labels on right-side without these side effects? note don't need second data series, it's closed i've come solution. long bars displayed normally, don't mind mechanism values on right hand side written.
you want linked axis http://jsfiddle.net/u5dhw/
xaxis: [{ categories: ['injustice: gods among ★', 'tekken tag tournament 2 ★', 'super smash bros. melee ★', 'persona 4 arena', 'king of fighters xiii', 'dead or alive 5 ultimate', 'street fighter x tekken ver. 2013', 'soulcalibur v'], }, { categories: ['fred', 'tom', 'bill', 'david', 'nathan', 'charles', 'mike', 'andrew'], linkedto: 0, opposite: true }],
Comments
Post a Comment