Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in data labels (bar chart) #328

Open
yuritatyanin opened this issue Apr 18, 2024 · 0 comments
Open

Possible error in data labels (bar chart) #328

yuritatyanin opened this issue Apr 18, 2024 · 0 comments

Comments

@yuritatyanin
Copy link

yuritatyanin commented Apr 18, 2024

First, I would like to say “Big thanks” to everyone involved in the direct development of this library :)
But I have a few questions about working with diagrams.
I use this code in my program:

QXlsx::Chart *barChart = _fileXls.insertChart(3, 3, QSize(600, 300));
barChart->setChartType(QXlsx::Chart::CT_BarChart);
QString range = QString("A5:B%1")
                .arg(5+info.productivityData.size()-1);
barChart->addSeries(QXlsx::CellRange(range),nullptr,true,false,false);

The data table consists of two columns and several rows of data, where the first row is the table title.
The result of the library is this:
photo_2024-04-18_11-08-06

The expected result is like this:
photo_2024-04-18_11-10-25

I started to figure it out and noticed these lines of code from the file xlsxchart.cpp

I commented out this block of code (91-93 line xlsxchart.cpp)

if (headerH) 
{
    firstDataRow += 1;
}

and corrected third argument subRange from range.firstRow() to range.lastRow() (106 line xlsxchart.cpp)

if (headerH) 
{
    CellRange subRange(range.firstRow(), col, range.lastRow(), col);
    series->headerH_numRef =
        sheetName + QLatin1String("!") + subRange.toString(true, true);
} 
else 
{
    series->headerH_numRef = QString();
}

I do not deny that I misunderstood something in the library code, but these edits helped solve my problem, but I did not test other events, etc.
And that’s why I didn’t make a pull request, but decided to ask a question)
@j2doll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant