Adjust horizontal (preferred) size of an XYPlot in JFreeChart - jfreechart

I have an XYPlot with an XYBarRenderer. This is used for a histogram. The horizontal spacing between the bins is too large, the bars are too wide. How can I decrease the 'preferred' bar width in this setting?
Note that setMaximumBarWidth is not defined for XYBarRenderer.

By default the XYBarRenderer will take its dimensions from the dataset which, in your case, will be determined by the actual bin widths. For presentation, you can override that and trim the bar widths down a little (or a lot) by calling the setMargin() method.

Related

ChartJS: Fixed width for data-part, the rest for labels

I'm using ChartJS to display multiple charts on a page.
Each chart has a different dataset, and different labels (some have short labels, some have long labels).
Currently the width of the actual 'data-part' (the part of the chart showing e.g. Bars) depends on how much space the labels take. I would like to make all charts have a fixed size for the data-part, and let the labels take up the remaining size.
See for example the following screenshot. Here I display 2 charts, but the actual data-part is different for both, because one has shorter labels than the other.
What I would like is to set for example a fixed width of 400px for the data-part, and let the labels take the remaining space left on the page. That way the charts would be aligned perfectly above each other.
Even better would be if I could set that for each chart the data-part takes a percentage of the width (e.g. 70%), so the labels take the rest (30%).
I have checked the ChartJS documentation, but the only I can find it setting the width for the entire chart-component.
Cheeky solution - you can add a dummy chart before your charts having the same labels.
Let's call this dummy chart as chart D and your main chart as chart M.
In M, you would fix it's width and hide the labels by writing in options -
scales: {y: {ticks: {display: false}}}
Now you have a fixed data width.
In D, you would just display the labels and hide the data part (hiding grid lines, legend, title, etc.).
So now you have two charts side-by-side, one is displaying just the labels and the other displaying the bars, just need to position it in such a way that no matter how long the label is, it does not overlap with M. Repeat the step similarly for all charts and have the same width for M1,M2,M3,...
This is a solution that seemed to work for me.

How customize column width in column series?

I would like to know if is possible to customize the column width of a bar graph.
Regards
Franco
Short answer, yes, see this, you should be able to customize everything in Live-Charts, by default MaxColumnWidth property is 35px, this means the bar will be capped at 35 px, no matter if there is more available space, if you change this property your bars will grow, mySeries.MaxColumnWidth = double.PositiveInfinity;
Playing with the column properties you can practically achieve any effect:
But it is a bit more complicated than that, bars will only have a greater width if there is enough space to grow, the width of any bar (ColumnSeries, RowSeries, StackedRow and StackedColumn), do always have a width of 1 chart unit, this because as you can notice the chart scales no matter what values you give to it, the next diagram explains a bit how it works:
For a bar series, the available space of a bar changes according to the number of visible bars:
You can only customize the max value, never the minimum dimension, in both previous cases the column width was capped by the MaxColumnWidth property, but notice when there are many bars, column's width needs to be less than 35px to be displayed correctly.

JFreeChart different fonts or font sizes in title

Is it possible to use different fonts or font sizes in the title of a JFreeChart object?
Using:
chart.getTitle().setFont(new Font("Tahoma", Font.PLAIN, 16));
allows one to set the font but I am trying to create a bold, large font-size title followed by an explanatory sub-title with smaller font size on the line below.
E.g. something like: "Intensive Care Infections / data from 2008-01-01 up to 2012-12-31"
Any other way to achieve this effect, if not possible in the title object?
You can add one or many subtitles using the addSubtitle() method in the JFreeChart class. The title is always drawn first, then the subtitles are drawn (by index order). Note that the legend is added to the chart as a "subtitle", so depending on the position you may want to insert your real subtitle at index 0 so that it is positioned and drawn before the legend.

How can I add padding to my chart?

As you can see from below my LineSeries chart (Silverlight Toolkit) utilize the whole area. How can I add a padding to it? So that the line does not stop/end/start at the border. For as you can see from the label it gets overlapped with the border, making it look less nice.
Why don't you increase the axis? Like: Vertical axis goes from 1000 to 9000 - and horizontal axis goes from 30.07 up to 08.08.
And: If you want to set margins to the whole control - doesn't margins / padding work for you?

SSRS. Autosize font to fit textbox width

Is it possible in SSRS to set the Font Size to auto? So the text fits exactly to the width of a text box?
Simply, no.
For practical reasons, some of which I can think of:
there is a lower bound to font size so some text will never fit
height changes too so for sparse text you get vertical growth

Resources