Menu

Displaying cells from example

2020-02-24
2020-03-25
  • Logan Courtney

    Logan Courtney - 2020-02-24

    I was using the MultiCharts.cpp example and it worked fine at first. I then changed the cell count to 15 and added my own data. This is the main code I changed. CorrelArr is full of doubles.

        const int DataCellCount = 15;
        // fill data sheet with randomly generated numbers
        for(int i = 0; i < 15; i++) {
            cellDbl.value = correlArr[i];
            data1.push_back(cellDbl);
            cellDbl.value = correlArr[i];
            data2.push_back(cellDbl);
        }
    
        FirstDataSheet.AddRow(data1).AddRow(data2); // data can be added by row or by cell
    
        // adding chart sheet to the workbook the reference to a newly created object is returned
        CChartsheet & ChartSheet = Book.AddChartSheet("Line Chart", CHART_LINEAR);
        // create series object, that contains most chart settings
        CChart::Series ser;
        // leave category sequence (X axis) not specified (optional) - MS Excel will generate the default sequence automatically
        ser.catSheet = NULL;
    
        // specify range for values` sequence (Y axis)
        ser.valAxisFrom = CellCoord(1, 0);
        ser.valAxisTo = CellCoord(1, DataCellCount);
        ser.valSheet =  & FirstDataSheet; // don`t forget to set the pointer to the data sheet
    
        ser.title = "rho_l";
        ser.JoinType = CChart::Series::joinSmooth;
    
        // add series into the chart (you can add as many series as you wish into the same chart)
        ChartSheet.Chart().AddSeries(ser);
    
        // second line to the chart
        CChart::Series ser2 = ser;
        ser2.valAxisFrom = CellCoord(2, 0);
        ser2.valAxisTo = CellCoord(2, DataCellCount);
        ser2.title = "I_l";
    

    When I look at the data in the Xlsx file. The charts are only plotting the very first cell of the row.

     
  • Alexandr Belyak

    Alexandr Belyak - 2020-02-25

    Hi,
    I just pasted your code in "MultiCharts.cpp" and everything works. Please see the attachment.
    Most likely the problem is in "CorrelArr". Make sure that its size is at least 15 elements and all elements have a finite value (not NaN, not Inf).
    Also check the values of the first two rows on the first sheet of created xlsx -file.

    If the problem persists, please attach your minimal non-working example and the created xlsx-file.

    P.S. For safety, use the "DataCellCount" in the loop below it.

     
    • Sergio C

      Sergio C - 2020-03-24

      Hello Alexandr Belyak,

      I have exactly the same problem as Logan.
      I tested your file "main.cpp" in VS2019 and the same problem appears... The chart is only plotting the very first cell of the row.
      Thank you very much for your assistance.

      Best regads.

       
  • Sergio C

    Sergio C - 2020-03-24

    Hello Alexandr Belyak,

    I have exactly the same problem as Logan.
    I tested your file "main.cpp" in VS2019 and the same problem appears... The chart is only plotting the very first cell of the row.
    Thank you very much for your assistance.

    Best regads.

     
  • Alexandr Belyak

    Alexandr Belyak - 2020-03-25

    Hi Sergio,
    Thanks for the information about the VS2019. This information helped to find and fix the bug.
    Please test the updated library from the attachment and let me know the results of your testing.
    Thank you again.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.