/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ import java.awt.Container; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.SwingUtilities; import ilog.views.chart.IlvAxis; import ilog.views.chart.IlvChart; import ilog.views.chart.data.IlvDefaultDataSource; import ilog.views.chart.interactor.IlvChartPanInteractor; import ilog.views.chart.interactor.IlvChartZoomInteractor; import ilog.views.chart.util.IlvArrays; import ilog.views.util.IlvProductUtil; public class AxisSync extends JFrame { static final int COUNT = 101; public AxisSync() { super("Axis Synchronization"); setDefaultCloseOperation(EXIT_ON_CLOSE); IlvChart topChart = new IlvChart(); // the topchart data source IlvDefaultDataSource ds = new IlvDefaultDataSource(new double[][] { IlvArrays.randomValues(COUNT, 0, 50) }, -1, new String[] { "Data Set 1" }, null); topChart.setDataSource(ds); // add some interactors to be able to play with the axis range topChart.addInteractor(new IlvChartZoomInteractor()); topChart.addInteractor(new IlvChartPanInteractor()); // the bottom chart. This chart shares the same x-axis with topChart. IlvChart bottomChart = new IlvChart(); ds = new IlvDefaultDataSource(new double[][] { IlvArrays.randomValues(COUNT, 0, 50) }, -1, new String[] { "Data Set 2" }, null); bottomChart.setDataSource(ds); // synchronixe the x-axis with the one from topchart. We also want to // synchronize the plotarea of both charts so that grids are aligned. bottomChart.synchronizeAxis(topChart, IlvAxis.X_AXIS, true); Container container = getContentPane(); container.setLayout(new GridLayout(2, 1)); container.add(topChart); container.add(bottomChart); setSize(600, 530); } public static void main(String[] args) { // This sample uses JViews Charts features. When deploying an // application that includes this code, you need to be in possession // of a Perforce JViews Charts Deployment license. IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Charts_Deployment); SwingUtilities.invokeLater(new Runnable() { Override public void run() { AxisSync frame = new AxisSync(); frame.setVisible(true); } }); } }