Background: I am adding x & y values to a XYSeries dataset so I can render a jfreechart. Each of the x and y values are read in from a text file and are doubles. I've set the x and y values equal to the array location of the text and printed them out to check results. They are currently printing the correct results.
The Problem: However, I'm having trouble adding the series to my XYSeriesCollection. So I created an XYSeries named series1 and added the two values in. Then when I go to add that series1 data to the XYSeriesCollection, it throws the: "This dataset already contains a series with the key Object 1" error.
The Question: What does this error mean, and how do I solve it?
Code:
    private void renderChartBtnActionPerformed(java.awt.event.ActionEvent evt) {                                               
        String manufacturer = "";
        
        XYSeriesCollection dcd = new XYSeriesCollection();
        
        String[] splitLine = new String[4];
        String[][] twoD_arr = new String[arraySize][4];
        int kount = 0;
        double dnum = 0;
        double dnum2 = 0;
        
         // Checks which radio button is selected and sets equal to manufacturer
        if (audiRB.isSelected()) {
            manufacturer = "Audi";
        }
        else if (volvoRB.isSelected()) {
            manufacturer = "Volvo";       
        }
        
        Iterator<String> itr = carData.iterator();
        while(itr.hasNext()){
            splitLine = itr.next().split(",");
            for(int i=0;i<=3;i++){
                twoD_arr[kount][i] = splitLine[i];
               
            }
            kount = kount + 1;
        }
        // Checks which data type is selected and adds data to series
        for(int i=0; i< twoD_arr.length; i++){
            if (pctShare.isSelected() && (twoD_arr[i][1]).equals(manufacturer)) {
                XYSeries series1 = new XYSeries("Object 1");
                                
                dnum = Double.parseDouble(twoD_arr[i][3]);
                dnum2 = Double.parseDouble(twoD_arr[i][0]);
                series1.add(dnum, dnum2);
                System.out.println(dnum);
                System.out.println(dnum2);
                dcd.addSeries(series1);
            } 
            else if (qtySold.isSelected() && (twoD_arr[i][1]).equals(manufacturer)) {
//                inum = Integer.parseInt(twoD_arr[i][2]);
//                dcd.setValue(inum, "Quantity Sold", twoD_arr[i][0]);
//                dcd.setValue(dnum, dnum, dnum);
//                System.out.println(twoD_arr[i][0] + twoD_arr[i][2]);
                     
            }                
        }
        
         // User selection of chart type        
         if( LineRB.isSelected()){
            jchart = ChartFactory.createXYLineChart("New Car Sales in Norway", "Date", manufacturer, dcd);
        }
        else if(AreaRB.isSelected()){
            jchart = ChartFactory.createXYAreaChart("New Car Sales in Norway", "Date", manufacturer, dcd, PlotOrientation.VERTICAL, true, true, false);
        }
        else if(barRB.isSelected()){
            jchart = ChartFactory.createXYStepAreaChart("New Car Sales in Norway", "Date", manufacturer, dcd, PlotOrientation.VERTICAL, true, true, false);       
        }
        else {
           jchart = null; 
        }
        
        // Add chart to panel
        ChartPanel chartPanel = new ChartPanel(jchart);
        inner_chart_pnl.removeAll();
        inner_chart_pnl.add(chartPanel);
        inner_chart_pnl.updateUI(); 
    }      
