Key colours JFreeCharts - colors

I'm generating stackedbarcharts and piecharts using jfreecharts. Both types of charts use the same labels. For example I have John, Mike, Sandra, Pushpalika in both. Is there a way I can ensure that the colour used to represent each person is the same across both types of charts?

In general if the series keys in your CategoryDataset (for the bar chart) are in the same order as the keys in your PieDataset (for the pie chart), the auto-selected colors will be the same on both charts. However, if you really want to be sure then you should set the colors manually, using PiePlot's setSectionPaint() method and the stacked bar renderer's setSeriesPaint() method.

Related

Combining a stacked chart with a bar chart

I'm using reportbuilder 3
I was wondering if there was a way to combine a stacked bar chart with a normal bar chart.
I've tried a work around which, whilst serves the purpose, doesn't to me, look particularly professional. If its not possible to combine the two I'd be willing to listen to any other workarounds, for example like getting the two charts closer together, no gap in the horizontal axis, having the vertical axis of the stacked chart to mirror that of the bar chart (the bar chart currently extends past the vertical axis in the stacked chart). Any suggestions welcome.
This is my design view, stack bar chart to the left and normal bar chart to the right
This is the output
This may not be achievable in your scenario but as I don;t know what your data looks like, it's hard to tell.
My approach would be to arrange the dataset to contain two categories and have one category contain one series value and the main category include everything except the main series value.
To create this data I created a dataset with the following query.
DECLARE #t TABLE(ColA varchar(10), ColB varchar(10), Amount int)
INSERT INTO #t VALUES
('Targeted', 'Cars', 1170),
('Targeted', 'Bikes', 2598),
('Targeted', 'Trains', 6515),
('Others', 'Others', 14069)
SELECT * FROM #t
I then added a single stacked column chart as follows
This gives us the following result.
It has the advantage that the scales will be based on all amounts and its very simple to do. It may however be an issue if you need to independently format the two sets of data.

Add line to Scatter Plot

I did a scatterplot with two data series (blue and orange in the picture).
The orange line you see that connects the dots I did manually and I am looking for a way to have this automatic through the chart menu in Excel. Any idea who this can be done?
I am using Excel version 2013
The chart type you are trying to create is called a Step Chart. Unfortunately Excel doesn't natively offer this chart type, but there are several ways to fake them in Excel. You can use an XY chart with Error Bars to produce the horizontal lines, or you can use a column chart with extra in-between data points to fill the gaps between your actual data points, and you can probably also use another hack where you tell Excel that the x axis is a date axis.
It's a bit hard to advise which approach would suit you best without knowing whether your actual data matches the example you've posted or whether it differs in some way. If you can elaborate further I'll amend this answer with some examples.
Edit: Since your data is as described, you should be able to use the approaches outlined at https://peltiertech.com/Excel/ChartsHowTo/StepChart.html
Or alternately, just add in extra coordinates to direct Excel where to draw the line:
...and then delete the markers of the data points you want to hide:

Excel: Z-Order of Series in Chart and Legend

I have a combo chart in excel, with clustered bar charts (for a box plot) and lines. I am trying to display the bar charts/box plot in front of the lines, but am able to do so.
I tried moving the bar charts to the top and/or bottom in "select data" - but no change.
Any suggestions?
Am using Excel 2013.
Thanks!
I believe it is not possible. You can change display ordering of Excel series by:
changing the plot order of the series (this is what you have done in the "Select data" dialog),
changing the axis on which the series are displayed (series on secondary axis are displayed over the series on the primary axis).
But from my experiments no combination of changes makes the lines appear behind the columns.
There are two workarounds that might or might not help you:
you can create two charts on top of each other and put the chart with the lines behind the one with the columns,
or you could create a line chart (most likely you would need scatter chart), that is not a single line but a series of segments where the columns are not shown (this one is not that easy to do)
What are the lines for? If you are just trying to identify some zones along the value axis, you could instead use stacked areas, which would give a banded appearance. Areas are always drawn behind bars and columns, while lines are always drawn in front of lines and columns.

Excel: Color Code Subset of Pie Charts

Hello, I was wondering if it is possible to color code groups of the pie chart together, but not manually do it slice by slice. For example, Apartments would be grouped together as light blue, and then Self Storage as dark blue. The pieces would retain their original percentage still though. This would make it easier to identify groups of data more easily. Any input?
Thanks in advance for the help.
Any input? Well, first, don't use pie charts for charts with more than two or three data points. They are hard to interpret. Use horizontal bar charts instead.
The data seems to be sorted by value. If you want to group by category, you will need to sort by category, too.
Excel will automatically apply a different color to each pie chart wedge. You can manually change these colors. You can use VBA to automate that.
A horizontal bar chart will give you a lot more tools to visualize the data and turn it into information.

Excel chart with countries in y-axis, % in x-axis, circles as markers and control groups

Do you know if this chart, as shown in the following image, can be done in Excel?
Chart:
I don't even know how this kind of chart is named, so I cannot search in the web for tutorials. I don't need to display three points on every row as in this chart (one is enough), and even I can mark the control group manually.
Yes this can be done in Excel.
If you want vertical orientation like on the picture above, then you should probably use the Scatter chart with quite some modifications. You would set the x values of the series to your values and the y values can be just 1,2,3,4,5.... The biggest problem with this approach would be how to display the correct categories. There is a tool to help you do that and it is discussed here: https://superuser.com/questions/485883/how-to-create-dynamic-scatter-plot-matrix-with-labels-and-categories-on-both-axi
For horizontal one you can use a normal line chart - with hidden line and only markers visible (Excel doesn't support vertical line graphs).
Even three groups are easy to do, you just need to add three series and format them accordingly.
The lines are also quite easy to do, you add minor / major gridlines to the chart and then format those as well.

Resources