/* * Copyright 2005 Joe Walker * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsx3.chart; import org.directwebremoting.ScriptBuffer; import org.directwebremoting.ScriptSessions; import org.directwebremoting.io.Context; /** * The data series type for a jsx3.chart.BarChart. Draws horizontal bars between the y axis and an x value determined by the data provider, or between two x values determined by the data provider. A bar series has the following fields: xField the attribute of a record to use as the horizontal extent of the bar, required yField the attribute of a record to use as the vertical midpoint of the bar, required if the y axis of the chart is a value axis minField the attribute of a record to use as the minimum horizontal extent of the bar, optional * @author Joe Walker [joe at getahead dot org] * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator */ public class BarSeries extends jsx3.chart.BCSeries { /** * All reverse ajax proxies need context to work from * @param context The script that got us to where we are now */ public BarSeries(Context context, String extension) { super(context, extension); } /** * The instance initializer. * @param name the GI name of the instance * @param seriesName the name of the Series, will be displayed in the Legend for most chart types */ public BarSeries(String name, String seriesName) { super((Context) null, (String) null); ScriptBuffer script = new ScriptBuffer(); script.appendCall("new BarSeries", name, seriesName); setInitScript(script); } /** * */ public static final int DEFAULT_BARHEIGHT = 10; /** * Returns the barHeight field. * @param callback barHeight */ public void getBarHeight(org.directwebremoting.ui.Callback<Integer> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getBarHeight"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the barHeight field. * @param barHeight the new value for barHeight */ public void setBarHeight(int barHeight) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setBarHeight", barHeight); ScriptSessions.addScript(script); } /** * The default tooltip function for this type of series. * @param series * @param record */ public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record, org.directwebremoting.ui.Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "tooltip", series, record); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } }