@@ -38,14 +38,20 int main(int argc, char *argv[]) | |||||
38 | chartView->setTitle("Basic line chart example"); |
|
38 | chartView->setTitle("Basic line chart example"); | |
39 | chartView->addSeries(series0); |
|
39 | chartView->addSeries(series0); | |
40 | chartView->addSeries(series1); |
|
40 | chartView->addSeries(series1); | |
41 | chartView->setChartBackgroundBrush(Qt::white); |
|
41 | ||
|
42 | ||||
|
43 | QLinearGradient backgroundGradient; | |||
|
44 | backgroundGradient.setColorAt(0.0, Qt::white); | |||
|
45 | backgroundGradient.setColorAt(1.0, QRgb(0xffff80)); | |||
|
46 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |||
|
47 | chartView->setChartBackgroundBrush(backgroundGradient); | |||
42 |
|
48 | |||
43 | QChartAxis axis = chartView->defaultAxisX(); |
|
49 | QChartAxis axis = chartView->defaultAxisX(); | |
44 | axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide); |
|
50 | axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide); | |
45 | axis.setGridPen(Qt::DashLine); |
|
51 | axis.setGridPen(Qt::DashLine); | |
46 |
|
52 | |||
47 | chartView->setDefaultAxisX(axis); |
|
53 | chartView->setDefaultAxisX(axis); | |
48 |
axis.setShadesBrush(Qt:: |
|
54 | axis.setShadesBrush(Qt::yellow); | |
49 | chartView->setDefaultAxisY(axis); |
|
55 | chartView->setDefaultAxisY(axis); | |
50 |
|
56 | |||
51 | window.setCentralWidget(chartView); |
|
57 | window.setCentralWidget(chartView); |
@@ -95,6 +95,7 void AxisItem::updateDomain() | |||||
95 | if(i%2){ |
|
95 | if(i%2){ | |
96 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2)); |
|
96 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2)); | |
97 | rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height()); |
|
97 | rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height()); | |
|
98 | rectItem->setOpacity( 0.5 ); | |||
98 | } |
|
99 | } | |
99 | } |
|
100 | } | |
100 | } |
|
101 | } | |
@@ -125,6 +126,7 void AxisItem::updateDomain() | |||||
125 | if(i%2){ |
|
126 | if(i%2){ | |
126 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2)); |
|
127 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2)); | |
127 | rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY); |
|
128 | rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY); | |
|
129 | ||||
128 | } |
|
130 | } | |
129 | } |
|
131 | } | |
130 | } |
|
132 | } | |
@@ -160,7 +162,7 void AxisItem::handleAxisChanged(const QChartAxis& axis) | |||||
160 | } |
|
162 | } | |
161 |
|
163 | |||
162 | if(axis.isShadesVisible()) { |
|
164 | if(axis.isShadesVisible()) { | |
163 |
setShadesOpacity( |
|
165 | setShadesOpacity(axis.shadesOpacity()); | |
164 | } |
|
166 | } | |
165 | else { |
|
167 | else { | |
166 | setShadesOpacity(0); |
|
168 | setShadesOpacity(0); |
@@ -240,6 +240,7 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item) | |||||
240 | axis.setLabelsBrush(Qt::black); |
|
240 | axis.setLabelsBrush(Qt::black); | |
241 | axis.setLabelsPen(Qt::NoPen); |
|
241 | axis.setLabelsPen(Qt::NoPen); | |
242 | axis.setShadesPen(Qt::NoPen); |
|
242 | axis.setShadesPen(Qt::NoPen); | |
|
243 | axis.setShadesOpacity(0.5); | |||
243 | item->handleAxisChanged(axis); |
|
244 | item->handleAxisChanged(axis); | |
244 | } |
|
245 | } | |
245 |
|
246 |
@@ -6,7 +6,8 QChartAxis::QChartAxis(): | |||||
6 | m_axisVisible(true), |
|
6 | m_axisVisible(true), | |
7 | m_gridVisible(true), |
|
7 | m_gridVisible(true), | |
8 | m_labelsVisible(true), |
|
8 | m_labelsVisible(true), | |
9 | m_shadesVisible(true) |
|
9 | m_shadesVisible(true), | |
|
10 | m_shadesOpacity(1.0) | |||
10 | { |
|
11 | { | |
11 | // TODO Auto-generated constructor stub |
|
12 | // TODO Auto-generated constructor stub | |
12 |
|
13 | |||
@@ -77,5 +78,9 void QChartAxis::setShadesBrush(const QBrush& brush) | |||||
77 | m_shadesBrush=brush; |
|
78 | m_shadesBrush=brush; | |
78 | } |
|
79 | } | |
79 |
|
80 | |||
|
81 | void QChartAxis::setShadesOpacity(qreal opacity) | |||
|
82 | { | |||
|
83 | m_shadesOpacity=opacity; | |||
|
84 | } | |||
80 |
|
85 | |||
81 | QTCOMMERCIALCHART_END_NAMESPACE |
|
86 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -49,6 +49,9 public: | |||||
49 | QPen shadesPen() const { return m_shadesPen;} |
|
49 | QPen shadesPen() const { return m_shadesPen;} | |
50 | void setShadesBrush(const QBrush& brush); |
|
50 | void setShadesBrush(const QBrush& brush); | |
51 | QBrush shadesBrush() const { return m_shadesBrush;} |
|
51 | QBrush shadesBrush() const { return m_shadesBrush;} | |
|
52 | void setShadesOpacity(qreal opacity); | |||
|
53 | qreal shadesOpacity() const { return m_shadesOpacity;} | |||
|
54 | ||||
52 |
|
55 | |||
53 |
|
56 | |||
54 | private: |
|
57 | private: | |
@@ -69,6 +72,9 private: | |||||
69 | QPen m_shadesPen; |
|
72 | QPen m_shadesPen; | |
70 | QBrush m_shadesBrush; |
|
73 | QBrush m_shadesBrush; | |
71 |
|
74 | |||
|
75 | qreal m_shadesOpacity; | |||
|
76 | ||||
|
77 | ||||
72 | LabelsOrientation m_labelsOrientation; |
|
78 | LabelsOrientation m_labelsOrientation; | |
73 | }; |
|
79 | }; | |
74 |
|
80 |
General Comments 0
You need to be logged in to leave comments.
Login now