SmartGWTPro 4.0 4/20/2014 build
With Zoom enabled, setting the zoom window to certain size causes the X-Axis labels on the main chart to overlap. See attached image.
This works most of the time, but when I change the zoom window to be a certain size (I'm guessing relative to the width of the whole chart) the main chart generate overlapping labels.
Test driver below. Note, I used a custom ValueFormatter for XAxis label to make the label extra long with extra junk text to help with testing. In our real life application, we have other long meaningful text.
With Zoom enabled, setting the zoom window to certain size causes the X-Axis labels on the main chart to overlap. See attached image.
This works most of the time, but when I change the zoom window to be a certain size (I'm guessing relative to the width of the whole chart) the main chart generate overlapping labels.
Test driver below. Note, I used a custom ValueFormatter for XAxis label to make the label extra long with extra junk text to help with testing. In our real life application, we have other long meaningful text.
Code:
public class SmartGwtTester implements EntryPoint { public void onModuleLoad() { final FacetChart chart = new FacetChart(); chart.setData(ChartData.getData()); chart.setID("chart"); chart.setWidth100(); chart.setHeight(550); chart.setFacets(new Facet("Time")); chart.setValueProperty("value"); chart.setChartType(ChartType.LINE); chart.setDataColors("#0000FF"); DrawLine dataLineProperties = new DrawLine(); dataLineProperties.setLineWidth(1); chart.setDataLineProperties(dataLineProperties); chart.setShowDataPoints(true); chart.setTitle("Line Chart with SmartGwt v" + Version.getVersion() + " build: " + Version.getBuildDate()); chart.setCanZoom(true); chart.setLabelCollapseMode(LabelCollapseMode.NUMERIC); chart.setShowLegend(false); chart.setMinLabelGap(10); chart.setRotateLabels(LabelRotationMode.NEVER); chart.setXAxisValueFormatter(new ValueFormatter() { @Override public String format(Object value) { if(value instanceof Number){ return ((Number)value).toString() + " Extra Extra Extra Extra Extra Extra"; } return null; } }); chart.addZoomChangedHandler(new ZoomChangedHandler() { @Override public void onZoomChanged(ZoomChangedEvent event) { System.out.println("Zoom range: " + event.getStartValue() + ", " + event.getEndValue()); } }); FacetChart zoomChart = new FacetChart(); zoomChart.setLogScale(false); // this line breaks the zoom chart flatline fix chart.setZoomChartProperties(zoomChart); chart.setZoomSelectionChartProperties(zoomChart); VLayout layout = new VLayout(15); layout.setWidth(1600); layout.setMembers(chart); chart.setZoomStartValue(10001); chart.setZoomEndValue(10670); layout.draw(); } public static class ChartData extends Record { public ChartData(float time, float value) { setAttribute("Time", time); setAttribute("value", value); } public static ChartData[] getData() { return new ChartData[] { new ChartData(10001f, 10.0f), new ChartData(10002f, 10.0f), new ChartData(10003f, 10.0f), new ChartData(10004f, 10.0f), new ChartData(10005f, 10.0f), new ChartData(10006f, 10.0f), new ChartData(10007f, 10.0f), new ChartData(10008f, 10.0f), new ChartData(10009f, 10.0f), new ChartData(10010f, 10.0f), new ChartData(10011f, 10.0f), new ChartData(10012f, 10.0f), new ChartData(10013f, 10.0f), new ChartData(10014f, 10.0f), new ChartData(10015f, 10.0f), new ChartData(10016f, 10.0f), new ChartData(10017f, 10.0f), new ChartData(10018f, 10.0f), new ChartData(10019f, 10.0f), new ChartData(10020f, 10.0f), // new ChartData(10021f, 10.1f), // uncomment so it's no longer a flat line, zoom chart will then show line new ChartData(20020f, 10.0f), }; } } }
Comment