Hi Isomorphic,
After looking around in the forums, I see that the way to modify formatting and change some properties of the X axis gradation labels is using setXAxisValueFormatter(). The problem is that after adding it to my FacetChart, the ValueFormatter is not being hit as expected, so the formatting is never applied. In the image you can see that the X axis labels are shown unmodified.
This is my test case base on this demo:
TestCases.java
ThreePlusAxesChartData.java
Thanks in advance for any help you can provide...
SmarGWT 6.0p 2016-06-22.
After looking around in the forums, I see that the way to modify formatting and change some properties of the X axis gradation labels is using setXAxisValueFormatter(). The problem is that after adding it to my FacetChart, the ValueFormatter is not being hit as expected, so the formatting is never applied. In the image you can see that the X axis labels are shown unmodified.
This is my test case base on this demo:
TestCases.java
Code:
public class TestCases implements EntryPoint { public void onModuleLoad() { FacetChart chart = new FacetChart(); chart.setWidth(600); chart.setHeight(400); chart.setChartType(ChartType.COLUMN); chart.setStacked(true); chart.setValueTitle("Percent"); chart.setBorder("1px solid black"); chart.setShowTitle(false); chart.setShowChartRect(true); Facet areaFacet = new Facet(); areaFacet.setValues(new FacetValue("1", "North America")); areaFacet.setId("area"); Facet metricFacet = new Facet(); metricFacet.setValues(new FacetValue("percent", "Percent"), new FacetValue("events", "Events"), new FacetValue("throughput", "Throughput")); metricFacet.setInlinedValues(true); metricFacet.setId("metric"); chart.setFacets(new Facet("date"), areaFacet, metricFacet); chart.setExtraAxisMetrics("events", "throughput"); MetricSettings metricSettingsEvents = new MetricSettings(); metricSettingsEvents.setChartType(ChartType.LINE); metricSettingsEvents.setMultiFacet(true); metricSettingsEvents.setShowDataPoints(true); metricSettingsEvents.setValueTitle("Events"); MetricSettings metricSettingsThroughput = new MetricSettings(); metricSettingsThroughput.setChartType(ChartType.AREA); metricSettingsThroughput.setMultiFacet(true); metricSettingsThroughput.setShowDataPoints(true); metricSettingsThroughput.setValueTitle("Throughput"); chart.setExtraAxisSettings(metricSettingsEvents, metricSettingsThroughput); chart.setData(ThreePlusAxesChartData.getData()); [B] chart.setXAxisValueFormatter(new ValueFormatter() { @Override public String format(Object value) { String date = (String) value; return date.substring(0, 6); } });[/B] HStack layout = new HStack(); layout.addMember(chart); layout.draw(); } }
Code:
public class ThreePlusAxesChartData extends Record { public ThreePlusAxesChartData(String area, String date, float percent, int events, int throughput) { setAttribute("area", area); setAttribute("date", date); setAttribute("percent", percent); setAttribute("events", events); setAttribute("throughput", throughput); } public static ThreePlusAxesChartData[] getData() { return new ThreePlusAxesChartData[] { new ThreePlusAxesChartData("1", "13 Sep 12", 0.55f, 8751, 20), new ThreePlusAxesChartData("2", "13 Sep 12", 0.32f, 3210, 24), new ThreePlusAxesChartData("3", "13 Sep 12", 0.21f, 2071, 28), new ThreePlusAxesChartData("1", "14 Sep 12", 0.49f, 6367, 30), new ThreePlusAxesChartData("2", "14 Sep 12", 0.41f, 3771, 36), new ThreePlusAxesChartData("3", "14 Sep 12", 0.22f, 2166, 39), new ThreePlusAxesChartData("1", "15 Sep 12", 0.7f, 6011, 41), new ThreePlusAxesChartData("2", "15 Sep 12", 0.19f, 1950, 45), new ThreePlusAxesChartData("3", "15 Sep 12", 0.25f, 2375, 48), new ThreePlusAxesChartData("1", "16 Sep 12", 0.47f, 9234, 51), new ThreePlusAxesChartData("2", "16 Sep 12", 0.25f, 4321, 55), new ThreePlusAxesChartData("3", "16 Sep 12", 0.3f, 909, 59), new ThreePlusAxesChartData("1", "17 Sep 12", 0.3f, 6144, 54), new ThreePlusAxesChartData("2", "17 Sep 12", 0.44f, 4077, 50), new ThreePlusAxesChartData("3", "17 Sep 12", 0.06f, 1477, 52), new ThreePlusAxesChartData("1", "18 Sep 12", 0.7f, 8502, 48), new ThreePlusAxesChartData("2", "18 Sep 12", 0.29f, 3061, 44), new ThreePlusAxesChartData("3", "18 Sep 12", 0.22f, 2955, 42), new ThreePlusAxesChartData("1", "19 Sep 12", 0.45f, 7020, 53), new ThreePlusAxesChartData("2", "19 Sep 12", 0.22f, 3040, 59), new ThreePlusAxesChartData("3", "19 Sep 12", 0.31f, 2177, 53), new ThreePlusAxesChartData("1", "20 Sep 12", 0.69f, 6712, 48), new ThreePlusAxesChartData("2", "20 Sep 12", 0.21f, 4981, 42), new ThreePlusAxesChartData("3", "20 Sep 12", 0.12f, 1234, 45), new ThreePlusAxesChartData("1", "21 Sep 12", 0.6f, 9321, 48), new ThreePlusAxesChartData("2", "21 Sep 12", 0.29f, 6532, 49), new ThreePlusAxesChartData("3", "21 Sep 12", 0.35f, 6622, 45), new ThreePlusAxesChartData("1", "22 Sep 12", 0.37f, 8389, 48), new ThreePlusAxesChartData("2", "22 Sep 12", 0.35f, 5104, 51), new ThreePlusAxesChartData("3", "22 Sep 12", 0.3f, 5111, 55), new ThreePlusAxesChartData("1", "23 Sep 12", 0.4f, 7555, 49), new ThreePlusAxesChartData("2", "23 Sep 12", 0.34f, 2345, 52), new ThreePlusAxesChartData("3", "23 Sep 12", 0.16f, 3456, 57), new ThreePlusAxesChartData("1", "24 Sep 12", 0.62f, 9567, 60), new ThreePlusAxesChartData("2", "24 Sep 12", 0.12f, 5678, 55), new ThreePlusAxesChartData("3", "24 Sep 12", 0.37f, 6789, 51) }; } }
SmarGWT 6.0p 2016-06-22.
Comment