/* * 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 lineSeries1: LineChart.Series = LineChart.Series { name: "Series 1" data: [ LineChart.Data { xValue: 0 yValue: 34 action:function(){Alert.inform("Clicked on 0,34")} }, LineChart.Data { xValue: 3 yValue: 27 action:function(){Alert.inform("Clicked on 3,27")} }, LineChart.Data { xValue: 6 yValue: 42 fill: Color.RED action:function(){Alert.inform("Clicked on 6,42")} }, LineChart.Data { xValue: 9 yValue: 50 }, LineChart.Data { xValue: 12 yValue: 64 symbol: PlotSymbol.Circle { size: 15 fill: Color.RED } }, LineChart.Data { xValue: 15 yValue: 56 }, LineChart.Data { xValue: 18 yValue: 48 }, LineChart.Data { xValue: 21 yValue: 34 }, LineChart.Data { xValue: 24 yValue: 30} ] symbolCreator: function(series:LineChart.Series, seriesIndex:Integer, item:LineChart.Data,itemIndex:Integer, fill:Paint){ PlotSymbol.HollowTriangle { fill: fill } } }; def lineSeries2: LineChart.Series = LineChart.Series { name: "Series 2" data: [ LineChart.Data { xValue: 0 yValue: 24 action:function(){Alert.inform("Clicked on 0,24")} }, LineChart.Data { xValue: 3 yValue: 17 action:function(){Alert.inform("Clicked on 3,17")} }, LineChart.Data { xValue: 6 yValue: -31 action:function(){Alert.inform("Clicked on 6,-31")} }, LineChart.Data { xValue: 9 yValue: -28 }, LineChart.Data { xValue: 12 yValue: -10 }, LineChart.Data { xValue: 15 yValue: -18 }, LineChart.Data { xValue: 18 yValue: 25 }, LineChart.Data { xValue: 21 yValue: 28 }, LineChart.Data { xValue: 24 yValue: 10 } ] symbolCreator: function(series:LineChart.Series, seriesIndex:Integer, item:LineChart.Data,itemIndex:Integer, fill:Paint){ PlotSymbol.Cross { fill: fill } } }; def lineSeries3: LineChart.Series = LineChart.Series { name: "Series 3" data: [ LineChart.Data { xValue: 0 yValue: 18 action:function(){Alert.inform("Clicked on 0,18")} }, LineChart.Data { xValue: 3 yValue: 25 action:function(){Alert.inform("Clicked on 3,25")} }, LineChart.Data { xValue: 6 yValue: 14 action:function(){Alert.inform("Clicked on 6,14")} }, LineChart.Data { xValue: 9 yValue: 18 }, LineChart.Data { xValue: 12 yValue: 22 }, LineChart.Data { xValue: 15 yValue: 16 }, LineChart.Data { xValue: 18 yValue: 14 }, LineChart.Data { xValue: 21 yValue: 12 }, LineChart.Data { xValue: 24 yValue: 8 } ] } def lineChart = LineChart { title: "Temperature Monitoring (in degree C)" data: [lineSeries1, lineSeries2, lineSeries3] xAxis: NumberAxis { side: Side.TOP label: "Time" lowerBound: 0 upperBound: 24 tickUnit: 2 formatTickLabel: function(value):String { "{(value as Float) as Integer}" } } yAxis: NumberAxis { side: Side.RIGHT label: "Temperature" lowerBound: -40 upperBound: 100 tickUnit: 20 } } Stage { title: "Line Chart" scene: Scene{ width: 540 height: 410 content: lineChart } //Scene }//Stage