/* * Isomorphic SmartGWT web presentation layer * Copyright 2000 and beyond Isomorphic Software, Inc. * * OWNERSHIP NOTICE * Isomorphic Software owns and reserves all rights not expressly granted in this source code, * including all intellectual property rights to the structure, sequence, and format of this code * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein. * * If you have any questions, please email
. * * This entire comment must accompany any portion of Isomorphic Software source code that is * copied or moved from this file. */ package com.smartgwt.sample.showcase.client.chart; import com.smartgwt.client.types.ChartType; import com.smartgwt.client.types.DataLineType; import com.smartgwt.client.types.FormItemType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.chart.FacetChart; import com.smartgwt.client.widgets.cube.Facet; import com.smartgwt.client.widgets.cube.FacetValue; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.VLayout; import java.util.Map; import java.util.HashMap; import com.google.gwt.core.client.EntryPoint; public class CustomTicksChart implements EntryPoint { @Override public void onModuleLoad() { final FacetChart chart = new FacetChart(); chart.setData(CustomTicksChartData.getData()); chart.setID("multiScatterChart"); chart.setWidth100(); chart.setShowXTicks(true); chart.setGradationGaps(2); chart.setOtherAxisGradationTimes("1m","1y"); chart.setMajorTickTimeIntervals("1q"); Facet metric = new Facet(); metric.setValues(new FacetValue("value"), new FacetValue("Time")); metric.setInlinedValues(true); metric.setId("metric"); Facet animal = new Facet(); animal.setId("animal"); chart.setFacets(metric, animal); chart.setValueProperty("value"); chart.setChartType(ChartType.SCATTER); chart.setShowScatterLines(true); chart.setDataLineType(DataLineType.SMOOTH); DynamicForm typeForm = new DynamicForm(); typeForm.setTitleWidth(120); typeForm.setWidth(220); final SelectItem gradationTimesItem = new SelectItem("times", "Gradation Times"); gradationTimesItem.setType("integer"); gradationTimesItem.setDefaultValue(0); gradationTimesItem.setWrapTitle(false); Map times = new HashMap(); times.put(0, "Month/Year"); times.put(1, "Month/Quarter/Year"); gradationTimesItem.setValueMap(times); gradationTimesItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { Integer value = (Integer)event.getValue(); chart.setOtherAxisGradationTimes(value == 0 ? new String[] {"1m", "1y"} : new String[] {"1m", "1q", "1y"}); } }); typeForm.setItems(gradationTimesItem); VLayout layout = new VLayout(15); layout.setMembers(typeForm, chart); layout.setMinBreadthMember(chart); layout.draw(); } }