/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. * * This file is available and licensed under the following license: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Sun Microsystems nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import javafx.stage.Stage; import javafx.scene.Scene; import javafx.stage.Alert; import javafx.scene.paint.Color; import javafx.scene.chart.*; import javafx.scene.chart.part.*; def bubbleData1: BubbleChart.Series = BubbleChart.Series { name: "1996" fill: Color.web("#ff5904") data: [ BubbleChart.Data { xValue:30 yValue:35 radius:116 /* toolTip:"Mango" */ action:function(){Alert.inform("Clicked on Mango")} }, BubbleChart.Data { xValue:42 yValue:60 radius:99 /* toolTip:"Apple" */ action:function(){Alert.inform("Clicked on Apple")} }, BubbleChart.Data { xValue:8 yValue:15 radius:33 /* toolTip:"Orange" */ action:function(){Alert.inform("Clicked on Orange")} }, BubbleChart.Data { xValue:22 yValue:30 radius:72 /* toolTip:"Strawberry" */ action:function(){Alert.inform("Clicked on Strawberry")} }, BubbleChart.Data { xValue:18 yValue:20 radius:55 /* toolTip:"Kiwi" */ }, BubbleChart.Data { xValue:25 yValue:41 radius:58 /* toolTip:"Tomato" */ }, BubbleChart.Data { xValue:12 yValue:17 radius:80 /* toolTip:"Cucumber" */ }, BubbleChart.Data { xValue:20 yValue:30 radius:105 /* toolTip:"Potato" */ } ] } def bubbleData2: BubbleChart.Series = BubbleChart.Series { name: "1997" fill: Color.web("#4371AB") data: [ BubbleChart.Data { xValue:14 yValue:35 radius:116 /* toolTip:"Mango" */ action:function(){Alert.inform("Clicked on Mango")} }, BubbleChart.Data { xValue:22 yValue:20 radius:99 /* toolTip:"Apple" */ action:function(){Alert.inform("Clicked on Apple")} }, BubbleChart.Data { xValue:28 yValue:25 radius:33 /* toolTip:"Orange" */ action:function(){Alert.inform("Clicked on Orange")} }, BubbleChart.Data { xValue:32 yValue:20 radius:72 /* toolTip:"Strawberry" */ }, BubbleChart.Data { xValue:38 yValue:20 radius:55 /* toolTip:"Kiwi" */ }, BubbleChart.Data { xValue:5 yValue:21 radius:58 /* toolTip:"Tomato" */ }, BubbleChart.Data { xValue:2 yValue:27 radius:80 /* toolTip:"Cucumber" */ }, BubbleChart.Data { xValue:12 yValue:20 radius:105 /* toolTip:"Potato" */ } ] } def bubbleChart = BubbleChart { title: "Bubble Chart" data: [bubbleData1, bubbleData2] radiusScale: 0.07 xAxis: NumberAxis { label: "Price (Bt./kg.)" lowerBound: -5 upperBound: 50 tickUnit: 5 formatTickLabel: function(value):String { "{(value as Float) as Integer}" } } yAxis: NumberAxis { label: "Original Cost (Bt./kg.)" lowerBound: 0 upperBound: 70 tickUnit: 10 formatTickLabel: function(value):String { "{(value as Float) as Integer}" } } } Stage { title: "Bubble Chart" scene: Scene{ width: 540 height: 410 content: bubbleChart } //Scene }//Stage