Remove padding in google chart? - charts

I'm wondering why google charts add a blank padding when not specifying the top/right/left axises.
Select the image and you'll find a huge padding except the bottom which is already filled & that's why, how to remove that?
Specifically, Talking about the right and left paddings.
Thank you.

You can use the chartArea option as follows:
options.chartArea = { left: '8%', top: '8%', width: "70%", height: "70%"};
More documentation can be viewed here:
https://developers.google.com/chart/interactive/docs/gallery/piechart#Configuration_Options

When using the Google Chart API you can eliminate the padding. I made an example Here.
The relevant parameter is chma.
According to the documentation:
You can specify the size of the chart's margins, in pixels. Margins are calculated inward from the specified chart size (chs); increasing the margin size does not increase the total chart size, but rather shrinks the chart area, if necessary.
You can try these parameters online in the Chart Playground HERE.
HTH!
Edit: Warning from Google
Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.

Unfortunately, as said in Chart Margins documentation you can set only the minimum margin on each side of the chart.
Google adds some unnecessary margin (mostly on top) itself and there is no parameter which can stop this behavior.

Related

How to achieve this kind of heatmap / bar chart with Chart.js

I have to build a horizontal bar with chartjs. I already built a few of them but its a bit different. The chart has 2 labels for the yAxis ("Storm Risk", "Ice Risk") and hours for the xAxes. I have to print out for every hour one of these different options with different colors ("Low", "Medium", "Hight") as ye can see in the screenshot attached.
This kind of bar chart usually the values are represented by the length of the bar and its a bit different.
Any suggestion?.
Thanks
The chart you want to implement is a sort of a "heatmap". As of now (Sep. 2018), Heatmap charts are not supported out of the box by Chart.js. However, you can make one out of a stacked bar chart (in this case, probably stacked horizontal bar chart?): make each stack size equal to one another and each item backgroundColor depending on the actual values being represented. Once this is done, you can override ticks and tooltips using with according callbacks. Legend can be implemented by one more bar chart with sample values and colors.
More details can be found in a related GitHub issue: https://github.com/chartjs/Chart.js/issues/4627
Another alternative would be to use a BubbleChart. The strategy would be similar - you would need to make all bubbles same size, but override their colors. However, provided the look in the question, stacked horizontal bar chart will be more suitable.
Another option for those who are still looking is to use chartjs-chart-matrix https://chartjs-chart-matrix.pages.dev/usage.html plugin.
Example of implementation with Chart.js v3: https://www.youtube.com/watch?v=bi04BgvNY6U

Make barWidth fix in barchart

I am using Charts library. I want to keep chart max width fix. I didn't find any way to restrict to some width.
There is a way to make sure the width of a bar is never more than a certain proportion of the screen width. For example setting the setVisibleXRangeMinimum to 10 means each bar will be around 1/10 of the screen width
barChart.setVisibleXRangeMinimum(10.0)
You can also set the maximum:
barChart.setVisibleXRangeMaximum(10.0)
Finally, I am able to find the problem in my code. I was adding long value for X, which was creating the problem. I corrected the X value and everything is perfect :)
BarChartDataEntry(x: Double(x_Value), y: Double(y_Value))

Unwanted word wrapping in caption

In a FusionCharts (version 3.4.0) 2D Bar chart, I found that the caption wraps to a second line when the bar labels are long. How do I prevent it from doing this so that the caption appears on one line?
Check out this jsFiddle to reproduce the problem:
http://jsfiddle.net/eZjjT/163/
-
To prevent wrapping of caption text in horizontal bar charts, you can specify the maximum percentage of width for data labels along the X-axis, using the “maxLabelWidthPercent” attribute.

Remove Space Between Bars in Bar Chart in Google Visualization API

I have a single data series and need the bars stacked right next to each other. What Google Visualization API call / property would help me accomplish this?
Set the bar.groupWidth option. You can either set it as an integer (number of pixels for the group to take up) or as a percent of the available space. In your case, I suggest using the percent:
bar: {
groupWidth: '100%'
}
That will remove all space from between adjacent bars.

Jasper Reports, Expanding a Band Based on the Data in a Chart

Is there a way to get a band to resize based on the amount of data presented in a gantt chart? I can get the number of rows that are in the chart, if that helps. It seems like there should be a way around this.
In otherwords, how does one dynamically resize a chart in JasperReports?
The solution to this is to put a text band right beside the chart and estimate the appropriate height, use a scriptlet to generate enough text that would end up being close to the right height. On the text box, stretch on oversize, and the band will increase. Stretch the chart to the band height.