QBarCategoryAxis Class

The QBarCategoryAxis class is used for manipulating chart's axis. More...

Header: #include <QBarCategoryAxis>
Instantiated By: BarCategoryAxis
Inherits: QAbstractAxis

Properties

Public Functions

QBarCategoryAxis(QObject *parent = Q_NULLPTR)
~QBarCategoryAxis()
void append(const QStringList &categories)
void append(const QString &category)
QString at(int index) const
QStringList categories()
void clear()
int count() const
void insert(int index, const QString &category)
QString max() const
QString min() const
void remove(const QString &category)
void replace(const QString &oldCategory, const QString &newCategory)
void setCategories(const QStringList &categories)
void setMax(const QString &max)
void setMin(const QString &min)
void setRange(const QString &minCategory, const QString &maxCategory)

Reimplemented Public Functions

virtual AxisType type() const

Signals

void categoriesChanged()
void countChanged()
void maxChanged(const QString &max)
void minChanged(const QString &min)
void rangeChanged(const QString &min, const QString &max)

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QBarCategoryAxis class is used for manipulating chart's axis.

QBarCategoryAxis can be setup to show axis line with tick marks, grid lines and shades. Categories are drawn between ticks. Note that you can use this also with lineseries too. See the Line and BarChart Example to learn how to do that.

Example code on how to use QBarCategoryAxis.


  QChartView *chartView = new QChartView;
  QBarSeries *series = new QBarSeries;
  // ...
  chartView->chart()->addSeries(series);
  chartView->chart()->createDefaultAxes();

  QBarCategoryAxis *axisX = new QBarCategoryAxis;
  QStringList categories;
  categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
  axisX->append(categories);
  axisX->setRange("Feb", "May");
  chartView->chart()->setAxisX(axisX, series);

Property Documentation

categories : QStringList

Defines the categories of axis

Access functions:

QStringList categories()
void setCategories(const QStringList &categories)

Notifier signal:

count : const int

The count of categories.

Access functions:

int count() const

Notifier signal:

void countChanged()

max : QString

Defines the maximum value on the axis.

Access functions:

QString max() const
void setMax(const QString &max)

Notifier signal:

void maxChanged(const QString &max)

min : QString

Defines the minimum value on the axis.

Access functions:

QString min() const
void setMin(const QString &min)

Notifier signal:

void minChanged(const QString &min)

Member Function Documentation

QBarCategoryAxis::QBarCategoryAxis(QObject *parent = Q_NULLPTR)

Constructs an axis object which is a child of parent.

QBarCategoryAxis::~QBarCategoryAxis()

Destroys the object

void QBarCategoryAxis::append(const QStringList &categories)

Appends categories to axis. A maximum of the axis will be changed to last category in categories. If there were no categories previously defined, minimum of axis will be also changed to first category in categories. A category has to be valid QStrings and can not be duplicated. Duplicated categories will not be appended.

void QBarCategoryAxis::append(const QString &category)

Appends category to axis. A maximum of the axis will be changed to last category. If there were no categories previously defined, minimum of axis will be also changed to category. A category has to be valid QStrings and can not be duplicated. Duplicated categories will not be appended.

QString QBarCategoryAxis::at(int index) const

Returns category at index. Index must be valid.

QStringList QBarCategoryAxis::categories()

Returns categories

Note: Getter function for property categories.

See also setCategories().

[signal] void QBarCategoryAxis::categoriesChanged()

Axis emits signal when the categories of the axis have changed.

Note: Notifier signal for property categories.

void QBarCategoryAxis::clear()

Removes all categories. Sets the maximum and minimum of the axis's range to QString::null.

int QBarCategoryAxis::count() const

Returns number of categories.

Note: Getter function for property count.

[signal] void QBarCategoryAxis::countChanged()

Axis emits signal when the count of categories has changed.

Note: Notifier signal for property count.

void QBarCategoryAxis::insert(int index, const QString &category)

Inserts category to axis at index. A category has to be valid QStrings and can not be duplicated. If category is prepended or appended to categories, minimum and maximum of axis is updated accordingly.

QString QBarCategoryAxis::max() const

Returns maximum category

Note: Getter function for property max.

See also setMax().

[signal] void QBarCategoryAxis::maxChanged(const QString &max)

Axis emits signal when max of axis has changed.

Note: Notifier signal for property max.

QString QBarCategoryAxis::min() const

Returns minimum category.

Note: Getter function for property min.

See also setMin().

[signal] void QBarCategoryAxis::minChanged(const QString &min)

Axis emits signal when min of axis has changed.

Note: Notifier signal for property min.

[signal] void QBarCategoryAxis::rangeChanged(const QString &min, const QString &max)

Axis emits signal when min or max of axis has changed.

void QBarCategoryAxis::remove(const QString &category)

Removes category from axis. Removing category which is currently maximum or minimum will affect the axis range.

void QBarCategoryAxis::replace(const QString &oldCategory, const QString &newCategory)

Replaces oldCategory with newCategory. If oldCategory does not exist on the axis nothing is done. A newCategory has to be valid QStrings and can not be duplicated. In case of replacing minimum or maximum category, minimum and maximum of axis is updated accordingly.

void QBarCategoryAxis::setCategories(const QStringList &categories)

Set categories and discards the old ones, range of axis is adjusted to match first and last category in categories. A category has to be valid QStrings and can not be duplicated.

Note: Setter function for property categories.

See also categories().

void QBarCategoryAxis::setMax(const QString &max)

Sets maximum category to max.

Note: Setter function for property max.

See also max().

void QBarCategoryAxis::setMin(const QString &min)

Sets minimum category to min.

Note: Setter function for property min.

See also min().

void QBarCategoryAxis::setRange(const QString &minCategory, const QString &maxCategory)

Sets range from minCategory to maxCategory

[virtual] AxisType QBarCategoryAxis::type() const

Reimplemented from QAbstractAxis::type().

Returns the type of the axis