All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xeiam.xchart.demo.charts.line.LineChart02 Maven / Gradle / Ivy

/**
 * Copyright 2011 - 2014 Xeiam LLC.
 *
 * 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 com.xeiam.xchart.demo.charts.line;

import java.util.ArrayList;
import java.util.List;

import com.xeiam.xchart.Chart;
import com.xeiam.xchart.Series;
import com.xeiam.xchart.SeriesColor;
import com.xeiam.xchart.SeriesLineStyle;
import com.xeiam.xchart.SeriesMarker;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.demo.charts.ExampleChart;

/**
 * Sine wave with customized series style
 * 

* * Demonstrates the following: *

    *
  • Customizing the series style properties */ public class LineChart02 implements ExampleChart { public static void main(String[] args) { ExampleChart exampleChart = new LineChart02(); Chart chart = exampleChart.getChart(); new SwingWrapper(chart).displayChart(); } @Override public Chart getChart() { // generates sine data int size = 30; List xData = new ArrayList(); List yData = new ArrayList(); for (int i = 0; i <= size; i++) { double radians = (Math.PI / (size / 2) * i); xData.add(i - size / 2); yData.add(size * Math.sin(radians)); } // Create Chart Chart chart = new Chart(800, 600); // Customize Chart chart.getStyleManager().setChartTitleVisible(false); chart.getStyleManager().setLegendVisible(false); // Series 1 Series series1 = chart.addSeries("y=sin(x)", xData, yData); series1.setLineColor(SeriesColor.PURPLE); series1.setLineStyle(SeriesLineStyle.DASH_DASH); series1.setMarkerColor(SeriesColor.GREEN); series1.setMarker(SeriesMarker.SQUARE); return chart; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy