/* * 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.paint.Paint; import javafx.scene.chart.*; import javafx.scene.chart.part.*; def scatterData1: ScatterChart.Series = ScatterChart.Series { name: "Equities" data: [ ScatterChart.Data { xValue:4.2 yValue:193.2 fill: Color.RED /* toolTip:"Script B1: 4.2 yrs., 193.2%" */ action:function(){Alert.inform("Clicked on B1: 4.2 yrs., 193.2%")} }, ScatterChart.Data { xValue:2.8 yValue:33.6 fill: Color.RED /* toolTip:"Script C2: 2.8 yrs., 33.6%" */ action:function(){Alert.inform("Clicked on C2: 2.8 yrs., 33.6%")} }, ScatterChart.Data { xValue:6.2 yValue:24.8 fill: Color.RED /* toolTip:"Script D3: 6.2 yrs., 24.8%" */ action:function(){Alert.inform("Clicked on D3: 6.2 yrs., 24.8%")} }, ScatterChart.Data { xValue:1 yValue:14 /* toolTip:"Script E4: 1 yrs., 14%" */}, ScatterChart.Data { xValue:1.2 yValue:26.4 /* toolTip:"Script F5: 1.2 yrs., 26.4%" */}, ScatterChart.Data { xValue:4.4 yValue:114.4 /* toolTip:"Script G6: 4.4 yrs., 114.4%" */}, ScatterChart.Data { xValue:8.5 yValue:323 /* toolTip:"Script H7: 8.5 yrs., 323%" */}, ScatterChart.Data { xValue:6.9 yValue:289.8 /* toolTip:"Script I8: 6.9 yrs., 289.8%" */}, ScatterChart.Data { xValue:9.9 yValue:287.1 /* toolTip:"Script J9: 9.9 yrs., 287.1%" */}, ScatterChart.Data { xValue:0.9 yValue:9 /* toolTip:"Script K10: 0.9 yrs., 9%" */}, ScatterChart.Data { xValue:8.8 yValue:140.8 /* toolTip:"Script L11: 8.8 yrs., 140.8%" */}, ScatterChart.Data { xValue:3.2 yValue:150.4 /* toolTip:"Script M12: 3.2 yrs., 150.4%" */}, ScatterChart.Data { xValue:1.1 yValue:-39.6 /* toolTip:"Script N13: 1.1 yrs., 39.6%" */}, ScatterChart.Data { xValue:4.8 yValue:172.8 /* toolTip:"Script O14: 4.8 yrs., 172.8%" */}, ScatterChart.Data { xValue:5.8 yValue:278.4 /* toolTip:"Script P15: 5.8 yrs., 278.4%" */}, ScatterChart.Data { xValue:3.5 yValue:52.5 /* toolTip:"Script Q16: 3.5 yrs., 52.5%" */}, ScatterChart.Data { xValue:2.9 yValue:84.1 /* toolTip:"Script R17: 2.9 yrs., 84.1%" */}, ScatterChart.Data { xValue:0.8 yValue:18.4 /* toolTip:"Script S18: 0.8 yrs., 18.4%" */}, ScatterChart.Data { xValue:8.9 yValue:26.7 /* toolTip:"Script T19: 8.9 yrs., 26.7%" */}, ScatterChart.Data { xValue:0.9 yValue:27 /* toolTip:"Script U20: 0.9 yrs., 27%" */}, ScatterChart.Data { xValue:5.3 yValue:148.4 /* toolTip:"Script V21: 5.3 yrs., 148.4%" */}, ScatterChart.Data { xValue:1.4 yValue:22.4 /* toolTip:"Script W22: 1.4 yrs., 22.4%" */}, ScatterChart.Data { xValue:8.1 yValue:137.7 /* toolTip:"Script X23: 8.1 yrs., 137.7%" */}, ScatterChart.Data { xValue:9.8 yValue:401.8 /* toolTip:"Script Y24: 9.8 yrs., 401.8%" */}, ScatterChart.Data { xValue:8.8 yValue:114.4 /* toolTip:"Script Z25: 8.8 yrs., 114.4%" */}, ScatterChart.Data { xValue:3.5 yValue:28 /* toolTip:"Script A26: 3.5 yrs., 28%" */}, ScatterChart.Data { xValue:4.9 yValue:117.6 /* toolTip:"Script B27: 4.9 yrs., 117.6%" */}, ScatterChart.Data { xValue:6.5 yValue:195 /* toolTip:"Script C28: 6.5 yrs., 195%" */}, ScatterChart.Data { xValue:4.8 yValue:76.8 /* toolTip:"Script D29: 4.8 yrs., 76.8%" */}, ScatterChart.Data { xValue:3 yValue:48 /* toolTip:"Script E30: 3 yrs., 48%" */}, ScatterChart.Data { xValue:6.2 yValue:192.2 /* toolTip:"Script F31: 6.2 yrs., 192.2%" */}, ScatterChart.Data { xValue:1.8 yValue:-12.6 /* toolTip:"Script G32: 1.8 yrs., 12.6%" */}, ScatterChart.Data { xValue:5.8 yValue:168.2 /* toolTip:"Script H33: 5.8 yrs., 168.2%" */}, ScatterChart.Data { xValue:6.9 yValue:179.4 /* toolTip:"Script I34: 6.9 yrs., 179.4%" */}, ScatterChart.Data { xValue:3.2 yValue:60.8 /* toolTip:"Script J35: 3.2 yrs., 60.8%" */}, ScatterChart.Data { xValue:9 yValue:18 /* toolTip:"Script K36: 9 yrs., 18%" */}, ScatterChart.Data { xValue:8.4 yValue:336 /* toolTip:"Script L37: 8.4 yrs., 336%" */}, ScatterChart.Data { xValue:1.9 yValue:39.9 /* toolTip:"Script M38: 1.9 yrs., 39.9%" */}, ScatterChart.Data { xValue:0.6 yValue:20.4 /* toolTip:"Script N39: 0.6 yrs., 20.4%" */}, ScatterChart.Data { xValue:8.2 yValue:65.6 /* toolTip:"Script O40: 8.2 yrs., 65.6%" */}, ScatterChart.Data { xValue:3.8 yValue:102.6 /* toolTip:"Script P41: 3.8 yrs., 102.6%" */}, ScatterChart.Data { xValue:8 yValue:40 /* toolTip:"Script Q42: 8 yrs., 40%" */}, ScatterChart.Data { xValue:2.7 yValue:64.8 /* toolTip:"Script R43: 2.7 yrs., 64.8%" */}, ScatterChart.Data { xValue:1.8 yValue:61.2 /* toolTip:"Script S44: 1.8 yrs., 61.2%" */}, ScatterChart.Data { xValue:8.9 yValue:62.3 /* toolTip:"Script T45: 8.9 yrs., 62.3%" */}, ScatterChart.Data { xValue:1.6 yValue:3.2 /* toolTip:"Script U46: 1.6 yrs., 3.2%" */}, ScatterChart.Data { xValue:0.8 yValue:31.2 /* toolTip:"Script V47: 0.8 yrs., 31.2%" */}, ScatterChart.Data { xValue:5.3 yValue:58.3 /* toolTip:"Script W48: 5.3 yrs., 58.3%" */}, ScatterChart.Data { xValue:3 yValue:54 /* toolTip:"Script X49: 3 yrs., 54%" */}, ScatterChart.Data { xValue:3.4 yValue:44.2 /* toolTip:"Script Y50: 3.4 yrs., 44.2%" */}, ScatterChart.Data { xValue:7.2 yValue:129.6 /* toolTip:"Script Z51: 7.2 yrs., 129.6%" */}, ScatterChart.Data { xValue:1.6 yValue:46.4 /* toolTip:"Script A52: 1.6 yrs., 46.4%" */}, ScatterChart.Data { xValue:8.7 yValue:400.2 /* toolTip:"Script B53: 8.7 yrs., 400.2%" */}, ScatterChart.Data { xValue:5.3 yValue:185.5 /* toolTip:"Script C54: 5.3 yrs., 185.5%" */}, ScatterChart.Data { xValue:3.3 yValue:125.4 /* toolTip:"Script D55: 3.3 yrs., 125.4%" */}, ScatterChart.Data { xValue:0.7 yValue:-25.2 /* toolTip:"Script E56: 0.7 yrs., 25.2%" */}, ScatterChart.Data { xValue:9.2 yValue:101.2 /* toolTip:"Script F57: 9.2 yrs., 101.2%" */}, ScatterChart.Data { xValue:1.7 yValue:11.9 /* toolTip:"Script G58: 1.7 yrs., 11.9%" */}, ScatterChart.Data { xValue:1.8 yValue:14.4 /* toolTip:"Script H59: 1.8 yrs., 14.4%" */}, ScatterChart.Data { xValue:2 yValue:16 /* toolTip:"Script I60: 2 yrs., 16%" */}, ScatterChart.Data { xValue:7.4 yValue:118.4 /* toolTip:"Script J61: 7.4 yrs., 118.4%" */}, ScatterChart.Data { xValue:8.8 yValue:343.2 /* toolTip:"Script K62: 8.8 yrs., 343.2%" */}, ScatterChart.Data { xValue:5.2 yValue:130 /* toolTip:"Script L63: 5.2 yrs., 130%" */}, ScatterChart.Data { xValue:9.8 yValue:196 /* toolTip:"Script M64: 9.8 yrs., 196%" */}, ScatterChart.Data { xValue:2.5 yValue:112.5 /* toolTip:"Script N65: 2.5 yrs., 112.5%" */}, ScatterChart.Data { xValue:1.3 yValue:52 /* toolTip:"Script O66: 1.3 yrs., 52%" */}, ScatterChart.Data { xValue:6.4 yValue:179.2 /* toolTip:"Script P67: 6.4 yrs., 179.2%" */}, ScatterChart.Data { xValue:8.8 yValue:114.4 /* toolTip:"Script Q68: 8.8 yrs., 114.4%" */}, ScatterChart.Data { xValue:1.9 yValue:70.3 /* toolTip:"Script R69: 1.9 yrs., 70.3%" */}, ScatterChart.Data { xValue:6.9 yValue:-6.9 /* toolTip:"Script S70: 6.9 yrs., 6.9%" */}, ScatterChart.Data { xValue:4.9 yValue:205.8 /* toolTip:"Script T71: 4.9 yrs., 205.8%" */}, ScatterChart.Data { xValue:9.4 yValue:413.6 /* toolTip:"Script U72: 9.4 yrs., 413.6%" */}, ScatterChart.Data { xValue:1.8 yValue:-14.4 /* toolTip:"Script V73: 1.8 yrs., 14.4%" */}, ScatterChart.Data { xValue:0.4 yValue:2.4 /* toolTip:"Script W74: 0.4 yrs., 2.4%" */}, ScatterChart.Data { xValue:3.2 yValue:121.6 /* toolTip:"Script X75: 3.2 yrs., 121.6%" */} ] symbolCreator: function(series:ScatterChart.Series, seriesIndex:Integer, item:ScatterChart.Data,itemIndex:Integer, fill:Paint) {PlotSymbol.HollowDiamond {fill: fill}} } def scatterData2: ScatterChart.Series = ScatterChart.Series { name: "Mutual Funds" data: [ ScatterChart.Data { xValue:1.4 yValue:32.2 /* toolTip:"Fund A: 1.4 yrs., 32.2%" */}, ScatterChart.Data { xValue:1.6 yValue:27 /* toolTip:"Fund B: 0.6 yrs., 27%" */}, ScatterChart.Data { xValue:4.7 yValue:230.3 /* toolTip:"Fund C: 4.7 yrs., 230.3%" */}, ScatterChart.Data { xValue:8.9 yValue:160.2 /* toolTip:"Fund D: 8.9 yrs., 160.2%" */}, ScatterChart.Data { xValue:3 yValue:-24 /* toolTip:"Fund E: 3 yrs., 24%" */}, ScatterChart.Data { xValue:2 yValue:94 /* toolTip:"Fund F: 2 yrs., 94%" */}, ScatterChart.Data { xValue:8.5 yValue:399.5 /* toolTip:"Fund G: 8.5 yrs., 399.5%" */}, ScatterChart.Data { xValue:6.9 yValue:289.8 /* toolTip:"Fund H: 6.9 yrs., 289.8%" */}, ScatterChart.Data { xValue:1.3 yValue:15.6 /* toolTip:"Fund I: 1.3 yrs., 15.6%" */}, ScatterChart.Data { xValue:7.1 yValue:333.7 /* toolTip:"Fund J: 7.1 yrs., 333.7%" */}, ScatterChart.Data { xValue:4.3 yValue:-98.9 /* toolTip:"Fund K: 4.3 yrs., 98.9%" */}, ScatterChart.Data { xValue:1.4 yValue:4.8 /* toolTip:"Fund L: 0.4 yrs., 4.8%" */}, ScatterChart.Data { xValue:5 yValue:230 /* toolTip:"Fund M: 5 yrs., 230%" */}, ScatterChart.Data { xValue:9.9 yValue:445.5 /* toolTip:"Fund N: 9.9 yrs., 445.5%" */}, ScatterChart.Data { xValue:3.9 yValue:70.2 /* toolTip:"Fund O: 3.9 yrs., 70.2%" */}, ScatterChart.Data { xValue:1.3 yValue:5.4 /* toolTip:"Fund P: 0.3 yrs., 5.4%" */}, ScatterChart.Data { xValue:5.9 yValue:271.4 /* toolTip:"Fund Q: 5.9 yrs., 271.4%" */}, ScatterChart.Data { xValue:5.9 yValue:177 /* toolTip:"Fund R: 5.9 yrs., 177%" */}, ScatterChart.Data { xValue:0.7 yValue:15.4 /* toolTip:"Fund S: 0.7 yrs., 15.4%" */}, ScatterChart.Data { xValue:4 yValue:24 /* toolTip:"Fund T: 4 yrs., 24%" */}, ScatterChart.Data { xValue:9.8 yValue:431.2 /* toolTip:"Fund U: 9.8 yrs., 431.2%" */}, ScatterChart.Data { xValue:8.3 yValue:132.8 /* toolTip:"Fund V: 8.3 yrs., 132.8%" */}, ScatterChart.Data { xValue:4.9 yValue:161.7 /* toolTip:"Fund W: 4.9 yrs., 161.7%" */}, ScatterChart.Data { xValue:3.9 yValue:187.2 /* toolTip:"Fund X: 3.9 yrs., 187.2%" */}, ScatterChart.Data { xValue:1.7 yValue:42.5 /* toolTip:"Fund Y: 1.7 yrs., 42.5%" */}, ScatterChart.Data { xValue:6.3 yValue:233.1 /* toolTip:"Fund Z: 6.3 yrs., 233.1%" */}, ScatterChart.Data { xValue:4.7 yValue:159.8 /* toolTip:"Fund A1: 4.7 yrs., 159.8%" */}, ScatterChart.Data { xValue:1.3 yValue:16.9 /* toolTip:"Fund A2: 1.3 yrs., 16.9%" */}, ScatterChart.Data { xValue:7.6 yValue:235.6 /* toolTip:"Fund A3: 7.6 yrs., 235.6%" */}, ScatterChart.Data { xValue:4.4 yValue:202.4 /* toolTip:"Fund A4: 4.4 yrs., 202.4%" */}, ScatterChart.Data { xValue:5.3 yValue:169.6 /* toolTip:"Fund A5: 5.3 yrs., 169.6%" */}, ScatterChart.Data { xValue:8 yValue:144 /* toolTip:"Fund A6: 8 yrs., 144%" */} ] symbolCreator: function(series:ScatterChart.Series, seriesIndex:Integer, item:ScatterChart.Data,itemIndex:Integer, fill:Paint){PlotSymbol.HollowTriangle {fill: fill}} } def scatterChart = ScatterChart { title: "Investment Overview" data: [scatterData1, scatterData2] xAxis: NumberAxis { label: "Age (years)" lowerBound: 0 upperBound: 10 minorTickVisible: false tickUnit: 1 formatTickLabel: function(value):String { "{(value as Float) as Integer}" } } yAxis: NumberAxis { label: "Returns till date" lowerBound: -100 upperBound: 500 tickUnit: 100 formatTickLabel: function(value):String { "{(value as Float) as Integer}" } } } Stage { title: "Scatter Chart" scene: Scene{ width: 540 height: 410 content: scatterChart } //Scene }//Stage