##// END OF EJS Templates
Use light outline color instead of dark for bar, area and scatter
Use light outline color instead of dark for bar, area and scatter

File last commit:

r555:e00d69c18a68
r653:f4e416c6727f
Show More
qchartaxis.cpp
396 lines | 6.9 KiB | text/x-c | CppLexer
#include "qchartaxis.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
\class QChartAxis
\brief The QChartAxis class is used for manipulating chart's axis
and for adding optional axes to the chart.
\mainclass
There is only one x Axis, however there can be multiple y axes.
Each chart series can be bound to exactly one Y axis and the share common X axis.
Axis can be setup to show axis line with ticks, gird lines and shades.
*/
/*!
\fn bool QChartAxis::isAxisVisible() const
\brief Returns if axis is visible
\sa setAxisVisible()
*/
/*!
\fn QPen QChartAxis::axisPen() const
\brief Returns pen used to draw axis and ticks.
\sa setAxisPen()
*/
/*!
\fn bool QChartAxis::isGridLineVisible() const
\brief Returns if grid is visible
\sa setGridLineVisible()
*/
/*!
\fn QPen QChartAxis::gridLinePen() const
\brief Returns pen used to draw grid.
\sa setGridLinePen()
*/
/*!
\fn bool QChartAxis::labelsVisible() const
\brief Returns if grid is visible
\sa setLabelsVisible()
*/
/*!
\fn QPen QChartAxis::labelsPen() const
\brief Returns the pen used to labels.
\sa setLabelsPen()
*/
/*!
\fn QBrush QChartAxis::labelsBrush() const
\brief Returns brush used to draw labels.
\sa setLabelsBrush()
*/
/*!
\fn QFont QChartAxis::labelsFont() const
\brief Returns font used to draw labels.
\sa setLabelsFont()
*/
/*!
\fn QFont QChartAxis::labelsAngle() const
\brief Returns angle used to draw labels.
\sa setLabelsAngle()
*/
/*!
\fn bool QChartAxis::shadesVisible() const
\brief Returns if shades are visible.
\sa setShadesVisible()
*/
/*!
\fn qreal QChartAxis::shadesOpacity() const
\brief Returns opacity of shades.
*/
/*!
\fn QPen QChartAxis::shadesPen() const
\brief Returns pen used to draw shades.
\sa setShadesPen()
*/
/*!
\fn QBrush QChartAxis::shadesBrush() const
\brief Returns brush used to draw shades.
\sa setShadesBrush()
*/
/*!
\fn qreal QChartAxis::min() const
\brief Returns minimum value on the axis.
\sa setMin()
*/
/*!
\fn qreal QChartAxis::max() const
\brief Returns maximim value on the axis.
\sa setMax()
*/
/*!
\fn void QChartAxis::minChanged(qreal min)
\brief Axis emits signal when \a min of axis has changed.
*/
/*!
\fn void QChartAxis::maxChanged(qreal max)
\brief Axis emits signal when \a max of axis has changed.
*/
/*!
\fn void QChartAxis::rangeChanged(qreal min, qreal max)
\brief Axis emits signal when \a min or \a max of axis has changed.
*/
/*!
\fn int QChartAxis::ticksCount() const
\brief Return number of ticks on the axis
\sa setTicksCount()
*/
/*!
\fn void QChartAxis::updated()
\brief \internal
*/
/*!
\fn void QChartAxis::handleAxisRangeChanged(qreal min, qreal max)
\brief \internal \a min \a max
*/
/*!
Constructs new axis object which is a child of \a parent. Ownership is taken by
QChatView or QChart when axis added.
*/
QChartAxis::QChartAxis(QObject* parent):QObject(parent),
m_axisVisible(true),
m_gridLineVisible(true),
m_labelsVisible(true),
m_labelsAngle(0),
m_shadesVisible(false),
m_shadesOpacity(1.0),
m_min(0),
m_max(0),
m_ticksCount(5)
{
}
/*!
Destructor of the axis object. When axis is added to chart, chart object takes ownership.
*/
QChartAxis::~QChartAxis()
{
}
/*!
Sets \a pen used to draw axis line and ticks.
*/
void QChartAxis::setAxisPen(const QPen& pen)
{
if (pen != m_axisPen) {
m_axisPen=pen;
emit updated();
}
}
/*!
Sets if axis and ticks are \a visible.
*/
void QChartAxis::setAxisVisible(bool visible)
{
if (m_axisVisible!=visible) {
m_axisVisible=visible;
emit updated();
}
}
/*!
Sets if grid line is \a visible.
*/
void QChartAxis::setGridLineVisible(bool visible)
{
if (m_gridLineVisible!=visible) {
m_gridLineVisible=visible;
emit updated();
}
}
/*!
Sets \a pen used to draw grid line.
*/
void QChartAxis::setGridLinePen(const QPen& pen)
{
if (m_gridLinePen!=pen) {
m_gridLinePen=pen;
emit updated();
}
}
/*!
Sets if axis' labels are \a visible.
*/
void QChartAxis::setLabelsVisible(bool visible)
{
if(m_labelsVisible!=visible) {
m_labelsVisible=visible;
emit updated();
}
}
/*!
Sets \a pen used to draw labels.
*/
void QChartAxis::setLabelsPen(const QPen& pen)
{
if(m_labelsPen!=pen) {
m_labelsPen=pen;
emit updated();
}
}
/*!
Sets \a brush used to draw labels.
*/
void QChartAxis::setLabelsBrush(const QBrush& brush)
{
if(m_labelsBrush!=brush) {
m_labelsBrush=brush;
emit updated();
}
}
/*!
Sets \a font used to draw labels.
*/
void QChartAxis::setLabelsFont(const QFont& font)
{
if(m_labelsFont!=font) {
m_labelsFont=font;
emit updated();
}
}
/*!
Sets \a angle for all the labels on given axis.
*/
void QChartAxis::setLabelsAngle(int angle)
{
if(m_labelsAngle!=angle) {
m_labelsAngle=angle;
emit updated();
}
}
/*!
Sets if shades are \a visible.
*/
void QChartAxis::setShadesVisible(bool visible)
{
if(m_shadesVisible!=visible) {
m_shadesVisible=visible;
emit updated();
}
}
/*!
Sets \a pen used to draw shades.
*/
void QChartAxis::setShadesPen(const QPen& pen)
{
if(m_shadesPen!=pen) {
m_shadesPen=pen;
emit updated();
}
}
/*!
Sets \a brush used to draw shades.
*/
void QChartAxis::setShadesBrush(const QBrush& brush)
{
if(m_shadesBrush!=brush) {
m_shadesBrush=brush;
emit updated();
}
}
/*!
Sets \a opacity of the shades.
*/
void QChartAxis::setShadesOpacity(qreal opacity)
{
if(m_shadesOpacity!=opacity) {
m_shadesOpacity=opacity;
emit updated();
}
}
/*!
Sets \a min value on the axis.
*/
void QChartAxis::setMin(qreal min)
{
setRange(min,m_max);
}
/*!
Sets \a max value on the axis.
*/
void QChartAxis::setMax(qreal max)
{
setRange(m_min,max);
}
/*!
Sets range from \a min to \a max on the axis.
*/
void QChartAxis::setRange(qreal min, qreal max)
{
bool changed = false;
if(m_min!=min) {
m_min=min;
changed=true;
emit minChanged(min);
}
if(m_max!=max) {
m_max=max;
changed=true;
emit maxChanged(max);
}
if(changed) {
emit rangeChanged(m_min,m_max);
}
}
/*!
Sets \a count for ticks on the axis.
*/
void QChartAxis::setTicksCount(int count)
{
if(m_ticksCount!=count) {
m_ticksCount=count;
emit ticksCountChanged(count);
}
}
/*!
Sets axis, shades, labels and grid lines to be visible.
*/
void QChartAxis::show()
{
m_axisVisible=true;
m_gridLineVisible=true;
m_labelsVisible=true;
m_shadesVisible=true;
emit updated();
}
/*!
Sets axis, shades, labels and grid lines to not be visible.
*/
void QChartAxis::hide()
{
m_axisVisible=false;
m_gridLineVisible=false;
m_labelsVisible=false;
m_shadesVisible=false;
emit updated();
}
void QChartAxis::handleAxisRangeChanged(qreal min, qreal max)
{
setRange(min,max);
}
void QChartAxis::handleAxisTicksChanged(int count)
{
setTicksCount(count);
}
#include "moc_qchartaxis.cpp"
QTCOMMERCIALCHART_END_NAMESPACE