Reputation: 475
I created a StackedBarChart with GroupedStackedBarRenderer for solving problem https://stackoverflow.com/questions/18349933/how-to-create-a-stacked-bar-chart-with-multiple-rows-inside-one-row.
I can have any number of column key and row key, group. Below, I attached some screenshots from my program.The problem is I could not get a standart view ( spaces betwen bars,too big bars if input is less, too thin bars which did not show text written inside it).Before implementing this usecase, I would use setMaxbarWidth but now it does not work.
Here are the code which I use to arrange bars.
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(new Color(238, 238, 238));
GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
//Some insertion here
KeyToGroupMap map = new KeyToGroupMap("A");
renderer.setSeriesToGroupMap(map);
renderer.setItemMargin(0.0);
/** causes to show bar width half of available space. */
renderer.setMaximumBarWidth(.5);
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
plot.setRenderer(renderer);
/** get number axis in plot.Number related axis .x axis in this graph. */
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
renderer.setBaseToolTipGenerator(new CustomToolTipGenerator(getGraphData()));
renderer.setBarPainter(new StandardBarPainter());
/** do not show thick in number axis label */
rangeAxis.setTickLabelsVisible(false);
rangeAxis.setTickMarksVisible(false);
rangeAxis.setAxisLineVisible(false);
CategoryAxis categoryAxis = plot.getDomainAxis();
categoryAxis.setCategoryMargin(0.05);
// categoryAxis.setLowerMargin(0.05);
// categoryAxis.setUpperMargin(0.05);
categoryAxis.setTickLabelsVisible(false);
categoryAxis.setTickMarksVisible(false);
categoryAxis.setAxisLineVisible(false);
I know that there are some methods(setlowerMargin, setCategoryMargin, setUpperMargin) of CategoryDomain.I have made some tries over these methods.But no success. I did not understand why space between bars are so wide.Please help me
picture with 3 column key and 6 group
picture with 2 column key and 4 group
picture with one column key and 2 group
Upvotes: 0
Views: 2742
Reputation: 475
I understand what is wrong with code. I have a wrong KeyToGroup map.I have not grouped any row key inside same groupKey.So I did not get desired view which I want.
Upvotes: 0