Summary: | improve legend and x axis label for multiple x vectors in one plot | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Nicolas Brisset <nicolas.brisset> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Solaris | ||
Latest Commit: | Version Fixed In: |
Description
Nicolas Brisset
2004-10-19 15:26:57 UTC
I'm not sure what is wrong with the legend, as it gives the curve name. If you have multiple curves then it gives multiple curve names. I would agree that the x auto-label only gives one x-vector, which can be misleading. CVS commit by arwalker: Display the various default labels (x, y and top) ensuring that each unique name is included once and only once. CCMAIL: 91681-done@bugs.kde.org M +43 -23 kst2dplot.cpp 1.294 --- kdeextragear-2/kst/kst/kst2dplot.cpp #1.293:1.294 @@ -2366,6 +2366,7 @@ static void EscapeSpecialChars(QString& void Kst2DPlot::GenerateDefaultLabels() { - int n_curves, i_curve, n_images; - QString xlabel, ylabel, toplabel; + QStringList xlabels, ylabels, toplabels; + QString label, xlabel, ylabel, toplabel; + int n_curves, i_curve, n_images, i_count; n_curves = Curves.count(); @@ -2373,29 +2374,47 @@ void Kst2DPlot::GenerateDefaultLabels() if (n_curves > 0) { - if (n_curves == 1) { - xlabel = Curves[0]->xLabel(); - ylabel = Curves[0]->yLabel(); - toplabel = Curves[0]->topLabel(); - } else { - xlabel = Curves[0]->xLabel(); - ylabel = QString::null; - toplabel = QString::null; + for( i_curve = 0; i_curve < n_curves; i_curve++) { + if (xlabels.findIndex(Curves[i_curve]->xLabel()) == -1) { + xlabels.append(Curves[i_curve]->xLabel()); + } + if (ylabels.findIndex(Curves[i_curve]->yLabel()) == -1) { + ylabels.append(Curves[i_curve]->yLabel()); + } + if (toplabels.findIndex(Curves[i_curve]->topLabel()) == -1) { + toplabels.append(Curves[i_curve]->topLabel()); + } + } - ylabel = Curves[0]->yLabel(); - toplabel = Curves[0]->topLabel(); - for (i_curve = 1; i_curve < n_curves - 1; i_curve++) { - ylabel += QString(", ") + Curves[i_curve]->yLabel(); - if (toplabel != Curves[i_curve]->topLabel()) { - toplabel += QString(", ") + Curves[i_curve]->topLabel(); + i_count = xlabels.count(); + for (i_curve = 0; i_curve < i_count; i_curve++) { + xlabel += xlabels[i_curve]; + if (i_curve < i_count-2) { + xlabel += QString(", "); + } else if (i_curve == i_count-2) { + xlabel += i18n(" and "); } } - ylabel = i18n("%1 and %2").arg(ylabel).arg(Curves[n_curves - 1]->yLabel()); - if (toplabel != Curves[i_curve]->topLabel() && - !Curves[i_curve]->topLabel().isEmpty()) { - toplabel = i18n("%1 and %2").arg(toplabel).arg(Curves[n_curves - 1]->topLabel()); + i_count = ylabels.count(); + for (i_curve = 0; i_curve < i_count; i_curve++) { + ylabel += ylabels[i_curve]; + if (i_curve < i_count-2) { + ylabel += QString(", "); + } else if (i_curve == i_count-2) { + ylabel += i18n(" and "); } } + + i_count = toplabels.count(); + for (i_curve = 0; i_curve < i_count; i_curve++) { + toplabel += toplabels[i_curve]; + if (i_curve < i_count-2) { + toplabel += QString(", "); + } else if (i_curve == i_count-2) { + toplabel += i18n(" and "); + } } + } + // // labels for images |