Hi,
Good Morning,
I need to add meta data information such as unit, copy-right, source and last modified date at the bottom in the chart as shown in attached snapshot as well but there is no extra space at the bottom. I tried with "addChartDrawnHandler" and explicitly I added some "DrawLabel" but sometime it override the x-axis values and legants. I also need to display this extra information in chart download as well but the same overriding issue is there in download as well.
Please can you suggest me how to achieve it without overriding x-axis label, values and legants.
Is it possible using padding or margin at the bottom of the chart?
Here is the code:
Thanks.
Good Morning,
Quote:
|
GWT version -> v9.0p_2013-07-29/PowerEdition Deployment (built 2013-07-29) |
Please can you suggest me how to achieve it without overriding x-axis label, values and legants.
Is it possible using padding or margin at the bottom of the chart?
Here is the code:
Code:
class SalesRecord extends Record {
SalesRecord(String name, Integer value) {
setAttribute("value", value);
setAttribute("name", name);
}
}
Record[] chartData = new Record[] { new SalesRecord("South Oma Block", 1000),
new SalesRecord("Mazebga", 543), new SalesRecord("Blcok 1(Kenya)", 1256),
new SalesRecord("Metema", 3452), new SalesRecord("Cap Saint Andre", 1800),
new SalesRecord("Block 23 (Aambia)", 1456), new SalesRecord("Block 5001", 700),
new SalesRecord("Block 31 (Zambia)", 567), new SalesRecord("Northwest Area", 150),
new SalesRecord("Eyasi", 2345), new SalesRecord("Somaliland - Berbera", 234),
new SalesRecord("Middle Aambezi", 240), new SalesRecord("Benhine", 200),
new SalesRecord("Rift Valley Block", 1450),
new SalesRecord("Puntland - Nugaal", 1400), new SalesRecord("Block 2", 2000),
new SalesRecord("Adigala", 500), };
final FacetChart simpleChart = new FacetChart();
Facet regionFacet = new Facet("name", "Name");
Facet productFacet = new Facet("value", "Value");
simpleChart.setFacets(regionFacet, productFacet);
simpleChart.setData(chartData);
simpleChart.setValueProperty("value");
simpleChart.setChartType(ChartType.BAR);
simpleChart.setTitle("Block Name and Acreage");
simpleChart.addChartDrawnHandler(new ChartDrawnHandler() {
@Override
public void onChartDrawn(ChartDrawnEvent event) {
int chartWidth = simpleChart.getWidth();
int labelWidth = chartWidth / 3;
DrawLabel label1 = new DrawLabel();
label1.setFontWeight("normal");
label1.setFontSize(9);
String sourceText = "Copyright by Company XYZ";
label1.setContents(sourceText);
label1.setTop(simpleChart.getHeight() - 50);
label1.setLeft(10);
DrawLabel label2 = new DrawLabel();
label2.setFontWeight("normal");
label2.setFontSize(9);
String date = DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(
new Date());
label2.setContents("Last Modified by : " + date);
label2.setTop(simpleChart.getHeight() - 50);
label2.setLeft(labelWidth + labelWidth + 10);
DrawLabel label3 = new DrawLabel();
label3.setFontWeight("normal");
label3.setFontSize(11);
label3.setFontWeight("BOLD");
label3.setTop(simpleChart.getHeight() - 50);
label3.setLeft(labelWidth + 20);
label3.setContents("Acreage (mi2)");
simpleChart.addDrawItem(label3, true);
simpleChart.addDrawItem(label1, true);
simpleChart.addDrawItem(label2, true);
}
});