0

I am not able to set bars width if there is only 1 or 2 bars in chart. I am using Rgraph in my angular 7 app. I am unable to set marginInner property value based on the number of bars. Is there any property to set the barwidth directly. enter image description here

Santhosh
  • 1,053
  • 1
  • 20
  • 45

1 Answers1

1

There's no property to set the width directly, but what you can do is put the logic for calculating the marginInner in the draw event or an exec() function. Here's an exec function example:

new RGraph.Bar({
    id: 'cvs',
    data: [8,4,6,3,5,1,5],
    options: {
    }
}).draw().exec(function (obj)
{
    // Calculate marginInner here,set it and call RGraph.redraw();
});

This means that it runs only once after the chart has been drawn so you can then access the data (with obj.data) and then calculate how big the margin should be.

Richard
  • 4,809
  • 3
  • 27
  • 46
  • I have found width property in your docs https://www.rgraph.net/canvas/bar.html#key-properties can i use that Richard – Santhosh Jun 02 '21 at 10:04
  • That link goes to the key properties section. If you're referring to the image in the question - that width is not something that you set - it's something that is reported by RGraph when you call the getShape method in an event listener. – Richard Jun 05 '21 at 09:42
  • Thank you will try it and let you know – Santhosh Jun 05 '21 at 12:44