0

I am trying to set correctly the x axis for every count in the dataset, but I do not get in the correct way. As in the dataset variable, I try saving the values I want from another object; when displaying them it looks like they are accumulating in the 0 value position.

This is the method which I use for creating the chart:

    public void createSampleData() {
        dataset = new XYSeries(TITLE_NAME);
        int numberOfPixels = 0;
        double[] wavelength;
        double[] spectrum;
        try {
            sts.deviceState();
            numberOfPixels = sts.getNumberOfPixels();
            wavelength = sts.getWavelength();
            spectrum = sts.getSpectum();
            
            for(int i = 0; i < numberOfPixels; i++) {
                dataset.add(spectrum[i], wavelength[i]);
            }
            
        }catch (NoDeviceFoundException e) {
            System.out.println(e.getMessage());
        }
        lineChart = ChartFactory.createXYLineChart(
                 TITLE_NAME,
                 X_AXIS_NAME,
                 Y_AXIS_NAME,
                 new XYSeriesCollection(dataset));

        lineChart.setAntiAlias(antialiasingstate);
        lineChart.removeLegend(); 
        lineChart.setTitle(TITLE_NAME);
        final XYPlot plot = (XYPlot) lineChart.getPlot();
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(Y_AXIS_MIN_VALUE, Y_AXIS_MAX_VALUE);
        chartPanel.setChart(lineChart);
    }

The way it looks: enter image description here

Is something around setting the plot I am missing?

trashgod
  • 200,320
  • 28
  • 229
  • 974
luarpy
  • 1
  • 2

0 Answers0