本文整理汇总了Java中javafx.scene.chart.XYChart.Series方法的典型用法代码示例。如果您正苦于以下问题:Java XYChart.Series方法的具体用法?Java XYChart.Series怎么用?Java XYChart.Series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.chart.XYChart
的用法示例。
在下文中一共展示了XYChart.Series方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected BubbleChart<Number, Number> createChart() {
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
final BubbleChart<Number,Number> bc = new BubbleChart<Number,Number>(xAxis,yAxis);
// setup chart
bc.setTitle("Advanced BubbleChart");
xAxis.setLabel("X Axis");
yAxis.setLabel("Y Axis");
// add starting data
XYChart.Series<Number,Number> series1 = new XYChart.Series<Number,Number>();
series1.setName("Data Series 1");
for (int i=0; i<20; i++) series1.getData().add(
new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
XYChart.Series<Number,Number> series2 = new XYChart.Series<Number,Number>();
series2.setName("Data Series 2");
for (int i=0; i<20; i++) series2.getData().add(
new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
bc.getData().addAll(series1, series2);
return bc;
}
示例2: addDataItemStrNum
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
if (chart.getData() == null) {
chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
}
if (chart.getData().isEmpty()) {
chart.getData().add(new XYChart.Series<String, Number>());
}
int sIndex = (int) (Math.random() * chart.getData().size());
XYChart.Series<String, Number> series = chart.getData().get(sIndex);
Set<String> existingYears = new HashSet<String>();
for (Data<String, Number> data : series.getData()) {
existingYears.add(data.getXValue());
}
int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
while (existingYears.contains(Integer.toString(randomYear))) {
randomYear++;
}
series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
示例3: getArraySeries
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private List<XYChart.Series<Number, Number>> getArraySeries(DataSource<double[]> source) {
List<XYChart.Series<Number, Number>> series = arraySeriesMap.computeIfAbsent(source, __ -> new ArrayList<>());
final double[] data = source.getData();
if (data.length < series.size()) {
while (series.size() != data.length) {
XYChart.Series<Number, Number> removed = series.remove(series.size() - 1);
realData.remove(removed);
visibleSeries.remove(removed);
}
} else if (data.length > series.size()) {
for (int i = series.size(); i < data.length; i++) {
XYChart.Series<Number, Number> newSeries = new XYChart.Series<>();
newSeries.setName(source.getName() + "[" + i + "]"); // eg "array[0]", "array[1]", etc
series.add(newSeries);
realData.put(newSeries, FXCollections.observableArrayList());
visibleSeries.computeIfAbsent(newSeries, createVisibleProperty);
}
}
return series;
}
示例4: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected AreaChart<Number,Number> createChart() {
final NumberAxis xAxis = new NumberAxis(0,128,8);
final NumberAxis yAxis = new NumberAxis(0,50,10);
final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
// setup chart
ac.setId("audioAreaDemo");
ac.setLegendVisible(false);
ac.setTitle("Live Audio Spectrum Data");
ac.setAnimated(false);
xAxis.setLabel("Frequency Bands");
yAxis.setLabel("Magnitudes");
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
// add starting data
XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
series.setName("Audio Spectrum");
//noinspection unchecked
series1Data = new XYChart.Data[(int)xAxis.getUpperBound()];
for (int i=0; i<series1Data.length; i++) {
series1Data[i] = new XYChart.Data<Number,Number>(i,50);
series.getData().add(series1Data[i]);
}
ac.getData().add(series);
return ac;
}
示例5: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected AreaChart<Number, Number> createChart() {
NumberAxis xAxis = new NumberAxis();
NumberAxis yAxis = new NumberAxis();
AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
// setup chart
ac.setTitle("Area Chart Example");
xAxis.setLabel("X Axis");
yAxis.setLabel("Y Axis");
// add starting data
for (int s=0;s<3;s++) {
XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
series.setName("Data Series "+s);
double x = 0;
while (x<95) {
series.getData().add(new XYChart.Data<Number,Number>(x, Math.random()*99));
x += 5 + (15*Math.random());
}
series.getData().add(new XYChart.Data<Number,Number>(99d, Math.random()*99));
ac.getData().add(series);
}
return ac;
}
示例6: addDataItemNumStr
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
if (chart.getData() == null) {
chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
}
if (chart.getData().isEmpty()) {
chart.getData().add(new XYChart.Series<Number, String>());
}
int sIndex = (int) (Math.random() * chart.getData().size());
XYChart.Series<Number, String> series = chart.getData().get(sIndex);
Set<String> existingYears = new HashSet<String>();
for (Data<Number, String> data : series.getData()) {
existingYears.add(data.getYValue());
}
int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
while (existingYears.contains(Integer.toString(randomYear))) {
randomYear++;
}
series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
示例7: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected BarChart<Number, String> createChart() {
final String[] years = {"2007", "2008", "2009"};
final CategoryAxis yAxis = new CategoryAxis();
final NumberAxis xAxis = new NumberAxis();
final BarChart<Number,String> bc = new BarChart<Number,String>(xAxis,yAxis);
// setup chart
bc.setTitle("Horizontal Bar Chart Example");
yAxis.setLabel("Year");
yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(years)));
xAxis.setLabel("Price");
// add starting data
XYChart.Series<Number,String> series1 = new XYChart.Series<Number,String>();
series1.setName("Data Series 1");
XYChart.Series<Number,String> series2 = new XYChart.Series<Number,String>();
series2.setName("Data Series 2");
XYChart.Series<Number,String> series3 = new XYChart.Series<Number,String>();
series3.setName("Data Series 3");
series1.getData().add(new XYChart.Data<Number,String>(567, years[0]));
series1.getData().add(new XYChart.Data<Number,String>(1292, years[1]));
series1.getData().add(new XYChart.Data<Number,String>(2180, years[2]));
series2.getData().add(new XYChart.Data<Number,String>(956, years[0]));
series2.getData().add(new XYChart.Data<Number,String>(1665, years[1]));
series2.getData().add(new XYChart.Data<Number,String>(2450, years[2]));
series3.getData().add(new XYChart.Data<Number,String>(800, years[0]));
series3.getData().add(new XYChart.Data<Number,String>(1000, years[1]));
series3.getData().add(new XYChart.Data<Number,String>(2800, years[2]));
bc.getData().add(series1);
bc.getData().add(series2);
bc.getData().add(series3);
return bc;
}
示例8: getChartData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private ObservableList<XYChart.Series<String, Double>> getChartData() {
double aValue = 0;
lperson= new Label();
ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList();
Series<String, Double> aSeries = new Series<String, Double>();
aSeries.setName("dates");
String qcount= "SELECT date, COUNT(date) FROM gateentry where type='"+lp+"' GROUP BY date";
DBConnect.connect();
try
{
ResultSet rec = DBConnect.stmt.executeQuery(qcount);
while(rec.next())
{
String date = rec.getString("date");
int count= rec.getInt("COUNT(date)");
aSeries.getData().add(new XYChart.Data(date, count));
aValue = aValue + Math.random() - .5;
}
} catch (SQLException e)
{
ErrorMessage.display("SQL Error", e.getMessage()+"\n error");
e.printStackTrace();
}
answer.addAll(aSeries);
return answer;
}
示例9: getChartData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public static ObservableList<XYChart.Series<String, Number>> getChartData()
{
Debugger.out("Diagramm getChartData says : Hello ! ");
if (Data != null || Data.get(0).equals(null))
{
resetData();
} else
{
Logger.out("ObservableList Data in Diagramm is already empty");
}
getKarteien();
getPunkte();
for (int i = 0; i < Stacks.size(); i++)
{
Series<String, Number> thisSerie = new Series<String, Number>();
thisSerie.setName(Stacks.get(i));
Number forChart = (Number) Punkte.get(i);
thisSerie.getData().add(new Data<String, Number>(Stacks.get(i), forChart));
Data.add(thisSerie);
}
return Data;
}
示例10: doZoom
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private void doZoom(final boolean x, final Number n1, final Number n2) {
final double min = Math.min(n1.doubleValue(), n2.doubleValue());
final double max = Math.max(n1.doubleValue(), n2.doubleValue());
if (max - min > 1) {
zoomed = true;
final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
while (it.hasNext()) {
final XYChart.Series<X, Y> s = it.next();
final Iterator<XYChart.Data<X, Y>> it2 = s.getData().iterator();
while (it2.hasNext()) {
final XYChart.Data<X, Y> d = it2.next();
final Object value;
if (x) {
value = d.getXValue();
} else {
value = d.getYValue();
}
if (value instanceof Number) {
final Number n = (Number) value;
final double dd = n.doubleValue();
if (dd < min || dd > max) {
it2.remove();
} else {
}
}
if (s.getData().isEmpty()) {
it.remove();
}
}
}
} else {
// System.out.println("Skip tiny zoom");
}
}
示例11: graphGenerator
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public void graphGenerator()
{
profitLineChart.getData().clear();
/*double max=totalSale[0],min=totalPurchase[0];
for(int i=1;i<7;i++)
{
if(max<totalSale[i])
max=totalSale[i];
if(min<totalPurchase[i])
min=totalPurchase[i];
}
profitAxis.setAutoRanging(false);
profitAxis.setUpperBound(max+100);
profitAxis.setLowerBound(-(min+100));
profitAxis.setTickUnit(200);*/
String date;
XYChart.Series profit=new XYChart.Series();
XYChart.Series sale=new XYChart.Series();
XYChart.Series purchase=new XYChart.Series();
for(int i=6;i>=0;i--)
{
date=day[i]+"-"+month[i]+"-"+year[i];
profit.getData().add(new XYChart.Data(date,sum[i]));
sale.getData().add(new XYChart.Data(date,totalSale[i]));
purchase.getData().add(new XYChart.Data(date,(totalPurchase[i]*-1)));
}
profit.setName("Profit");
sale.setName("Sale");
purchase.setName("Purchase");
profitLineChart.getData().addAll(purchase,sale,profit);
}
示例12: getChartData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private ObservableList<XYChart.Series<String, Double>> getChartData() {
double aValue = 0;
ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList();
Series<String, Double> aSeries = new Series<String, Double>();
aSeries.setName("dates");
String qcount= "SELECT date, COUNT(date) FROM officeentry GROUP BY date";
DBConnect.connect();
try
{
ResultSet rec = DBConnect.stmt.executeQuery(qcount);
while(rec.next())
{
String date = rec.getString("date");
int count= rec.getInt("COUNT(date)");
aSeries.getData().add(new XYChart.Data(date, count));
aValue = aValue + Math.random() - .5;
}
} catch (SQLException e)
{
ErrorMessage.display("SQL Error", e.getMessage()+"\n error");
e.printStackTrace();
}
answer.addAll(aSeries);
return answer;
}
示例13: updateFromNumberSource
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private void updateFromNumberSource(DataSource<? extends Number> source) {
final long now = Time.now();
final XYChart.Series<Number, Number> series = getNumberSeries(source);
// The update HAS TO run on the FX thread, otherwise we run the risk of ConcurrentModificationExceptions
// when the chart goes to lay out the data
FxUtils.runOnFxThread(() -> {
updateSeries(series, now, source.getData().doubleValue());
});
}
示例14: createSeries
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
/**
* set series of content to draw chart and adapt to cpu threads
*/
public void createSeries() {
Float[] seriesValues = SingletonDynamicGeneralStats.getInstance().getPercPerThread();
series = Stream.<XYChart.Series<String, Number>>generate(XYChart.Series::new).limit(seriesValues.length).toArray(XYChart.Series[]::new);
for (int i = 0;i<series.length;i++){
series[i] = new XYChart.Series();
series[i].setName("Thread " + i);
multiLineChart.getData().add(series[i]);
}
}
示例15: setSeriesColor
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public void setSeriesColor(final XYChart.Series<X, Y> SERIES, final Paint COLOR) {
Background symbolBackground = new Background(new BackgroundFill(COLOR, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
setSeriesColor(SERIES, COLOR, COLOR, symbolBackground, COLOR);
}