We suggest not to set width/height property unless it is really required. When you don’t set the width/height, CanvasJS automatically takes the size of its container and hence works well with responsive websites where container’s size might change depending on the device from which it is being used.
var chart = new CanvasJS.Chart("container",
{
.
.
width: 320,
.
.
});
chart.render();
As of now it is not possible to reduce/set width of individual bars. They are decided automatically based on the number of dataPoints.
Air8426 says:
Example for horizontal bar.
1. you need to define the height of single bar, and calculate all bar height.
such as
var _height = arr.length * 50; // 50 means bar height
2. to define height of the html body.
ex.
$(‘#chartContainer’).attr(‘style’,”height: “+ _height+”px; width: 100%;”);
3. set the parameter ‘height’ with CanvasJS.Chart
ex.
var chart = new CanvasJS.Chart(“chartContainer”,
{
title:{text: chart_title },
height : _height,
…
}
try it :D
madhu says:
I have increased my column graph width but for last bars tool tip is not visible . ie it will not be displayed after some width.
Anjali says:
madhu,
Can you please create a jsfiddle so that we can have a look ?
Mauricio hernandez says:
Hi, this is my http://jsfiddle.net/jpgrnow1/2/ I created a bar char but en my xaxis hide the name, whe I resize my browser they appers. I want to show always the xaxis name
Anjali says:
mauricio,
When you have more number of columns then chart automatically skips some of the labels to avoid overlapping. But you can force it to show all labels by setting interval property of axisX to 1.
manimaran.S says:
its possible to add 100% for width..
Naveen Venugopal says:
Currently only pixel value can be set to width, we will support percent value in our future version.
Sunil Urs says:
Manimaran,
Charts take up 100% of the width of its container by default if you don’t set any value.
Tejas Masurkar says:
Hello Do we have any property to decided bar size??
Vishwas R says:
Tejas,
You can use dataPointWidth to set the width of column or bar.
Jagadesan says:
Hi All, How I can increase the grid width of chartcontainer?
If you have any questions, please feel free to ask in our forums. Ask Question
Due to multiple records few of records(columns) get hide in left section of graph and right section of the graph.
Rajesh,
Can you please create a jsfiddle and post it into our forum so that we can have a look?.
i had created two charts in one page but it shows only once in one time. How can i show both chart in one page at one time.
Jayant,
Please refer this example.
In the above Anjali’s example can we add a padding before each x axis values?
how to reduce the bar width in above example
As of now it is not possible to reduce/set width of individual bars. They are decided automatically based on the number of dataPoints.
Example for horizontal bar.
1. you need to define the height of single bar, and calculate all bar height.
such as
var _height = arr.length * 50; // 50 means bar height
2. to define height of the html body.
ex.
$(‘#chartContainer’).attr(‘style’,”height: “+ _height+”px; width: 100%;”);
3. set the parameter ‘height’ with CanvasJS.Chart
ex.
var chart = new CanvasJS.Chart(“chartContainer”,
{
title:{text: chart_title },
height : _height,
…
}
try it :D
I have increased my column graph width but for last bars tool tip is not visible . ie it will not be displayed after some width.
madhu,
Can you please create a jsfiddle so that we can have a look ?
Hi, this is my http://jsfiddle.net/jpgrnow1/2/ I created a bar char but en my xaxis hide the name, whe I resize my browser they appers. I want to show always the xaxis name
mauricio,
When you have more number of columns then chart automatically skips some of the labels to avoid overlapping. But you can force it to show all labels by setting interval property of axisX to 1.
its possible to add 100% for width..
Currently only pixel value can be set to width, we will support percent value in our future version.
Manimaran,
Charts take up 100% of the width of its container by default if you don’t set any value.
Hello Do we have any property to decided bar size??
Tejas,
You can use dataPointWidth to set the width of column or bar.
Hi All, How I can increase the grid width of chartcontainer?