GroupedStackedBarRenderer
을 사용할 수있는 플롯을 만들기 위해 JFreeChart (StackedBarChartDemo5)의 데모를 따라했습니다.JFreeChart에서 GroupedStackedBarRenderer를 사용할 때 그룹 라벨을 회전하는 방법은 무엇입니까?
기본적으로 나는 각 스테이션 (막대의 스택을 나타냄)에 대한 대기 시간을 표시하고 라디오 (플롯의 막대를 나타냄), 수신 및 전송 (RX 및 TX) 모두에 연결합니다.
은 두 가지 범주 (RX 및 TX) 및 여러 그룹 (라디오)가 있습니다
줄거리는 다음과 같이 보인다. 보시다시피 현재, 무선 MAC은 읽을 수 없습니다. 음모를 읽기 쉽도록 만들기 위해이 라벨을 회전하고 싶습니다.
나는 시도하기 위해 다음 코드 조각을 사용하여 레이블을 회전 한 : subCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI/4));
이 범주 만의 라벨 (RX 및 TX) 대신 그룹의 라벨 (무선 맥) 회전 :
다른 접근법을 시도해 보았습니다.이 접근법은 아무데도 이어지지 않습니다 ... 어떻게 이러한 서브 레이블을 회전합니까?
subCategoryAxis.setLabelAngle(-Math.PI/2);
: 당신은 라디안 CategoryAxis
에 회전을 설정할 수 있습니다
SubCategoryAxis subCategoryAxis = new SubCategoryAxis("Radio MACs (separate Rx and Tx plots)");
subCategoryAxis.setCategoryMargin(0.05D);
// subCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI/4));
KeyToGroupMap keyToGroupMap = null;
final Set<String> radios = Sets.newHashSet();
for (Entry<XRadio, Triplet<XStation, Double, Double>> entryMap: channelTimes.entries()) {
final String radioMac = entryMap.getKey().getMac();
if (keyToGroupMap == null)
keyToGroupMap = new KeyToGroupMap(radioMac);
if (!radios.contains(radioMac)) {
subCategoryAxis.addSubCategory(radioMac);
radios.add(radioMac);
}
final Triplet<XStation, Double, Double> chTriplet = entryMap.getValue();
final String seriesKey = radioMac + ":" + chTriplet.a.getMac();
keyToGroupMap.mapKeyToGroup(seriesKey, radioMac);
model.getDataset().addValue(chTriplet.b, seriesKey, "Rx");
model.getDataset().addValue(chTriplet.c, seriesKey, "Tx");
}
if (keyToGroupMap == null)
return;
groupedStackedBarRenderer.setSeriesToGroupMap(keyToGroupMap);
groupedStackedBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
groupedStackedBarRenderer.setBaseItemLabelsVisible(true);
groupedStackedBarRenderer.setItemMargin(0.1D); // 10 %
groupedStackedBarRenderer.getPlot().setDomainAxis(subCategoryAxis);
[JFreeChart에서 숫자 축 도메인의 눈금 라벨을 어떻게 회전합니까?] (http://stackoverflow.com/questions/7071057/how-do)에 나와있는 방법 중 하나를 사용할 수 있습니다. -i-rotate-tick-mark-the-number-of-a-axis-in-jfreechart에있는 레이블). – trashgod