##// END OF EJS Templates
Fixed a bug in ChartView.axes property when no series added
Tero Ahola -
r2300:20fb6c76ccf2
parent child
Show More
@@ -560,7 +560,7 int DeclarativeChart::axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *lis
560 {
560 {
561 if (qobject_cast<DeclarativeChart *>(list->object)) {
561 if (qobject_cast<DeclarativeChart *>(list->object)) {
562 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
562 DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object);
563 return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]).count();
563 return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count();
564 }
564 }
565 return 0;
565 return 0;
566 }
566 }
@@ -115,20 +115,20 public:
115 int count();
115 int count();
116 void setDropShadowEnabled(bool enabled);
116 void setDropShadowEnabled(bool enabled);
117 bool dropShadowEnabled();
117 bool dropShadowEnabled();
118
119 // Margins & plotArea
118 qreal topMargin();
120 qreal topMargin();
119 qreal bottomMargin();
121 qreal bottomMargin();
120 qreal leftMargin();
122 qreal leftMargin();
121 qreal rightMargin();
123 qreal rightMargin();
122 QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series);
123 void initializeAxes(QAbstractSeries *series);
124 void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes);
125 //TODO this is deprecated:
126 DeclarativeMargins *minimumMargins() { return m_margins; }
124 DeclarativeMargins *minimumMargins() { return m_margins; }
127
128 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
125 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
129 QRectF plotArea() { return m_chart->plotArea(); }
126 QRectF plotArea() { return m_chart->plotArea(); }
130
127
131 // Axis list property methods
128 // Axis handling
129 QAbstractAxis *defaultAxis(Qt::Orientation orientation, QAbstractSeries *series);
130 void initializeAxes(QAbstractSeries *series);
131 void doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes);
132 QDeclarativeListProperty<QAbstractAxis> axes();
132 QDeclarativeListProperty<QAbstractAxis> axes();
133 static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element);
133 static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element);
134 static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list);
134 static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list);
@@ -62,7 +62,7 Rectangle {
62 // Legend font
62 // Legend font
63 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
63 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
64 compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization");
64 compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization");
65 compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family");
65 verify(chartView.legend.font.family != "", "ChartView.legend.font.family");
66 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
66 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
67 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
67 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
68 verify(chartView.legend.font.pixelSize > 0
68 verify(chartView.legend.font.pixelSize > 0
@@ -73,6 +73,7 Rectangle {
73 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
73 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
74 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
74 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
75 compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing");
75 compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing");
76 compare(chartView.axes.length, 0, "ChartView.axes.length");
76 }
77 }
77 }
78 }
78
79
@@ -58,7 +58,7 Rectangle {
58 // Legend font
58 // Legend font
59 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
59 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
60 compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization");
60 compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization");
61 compare(chartView.legend.font.family, "arial", "ChartView.legend.font.family");
61 verify(chartView.legend.font.family != "", "ChartView.legend.font.family");
62 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
62 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
63 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
63 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
64 verify(chartView.legend.font.pixelSize > 0
64 verify(chartView.legend.font.pixelSize > 0
@@ -32,10 +32,10 Rectangle {
32 when: windowShown
32 when: windowShown
33
33
34 function test_defaultPropertyValues() {
34 function test_defaultPropertyValues() {
35 compare(lineSeries1.axisX.min, 0, "AxisX min");
35 verify(axisX.min < 0, "AxisX min");
36 compare(lineSeries1.axisX.max, 10, "AxisX max");
36 verify(axisX.max > 0, "AxisX max");
37 compare(lineSeries1.axisY.min, 0, "AxisY min");
37 verify(axisY.min < 0, "AxisY min");
38 compare(lineSeries1.axisY.max, 10, "AxisY max");
38 verify(axisY.max > 0, "AxisY max");
39 verify(axisX.tickCount > 0, "AxisX tick count");
39 verify(axisX.tickCount > 0, "AxisX tick count");
40 verify(axisY.tickCount > 0, "AxisX tick count");
40 verify(axisY.tickCount > 0, "AxisX tick count");
41 compare(axisX.niceNumbersEnabled, false, "nice numbers");
41 compare(axisX.niceNumbersEnabled, false, "nice numbers");
@@ -43,14 +43,16 Rectangle {
43 }
43 }
44
44
45 function test_modifyProperties() {
45 function test_modifyProperties() {
46 lineSeries1.axisX.tickCount = 3;
46 axisX.tickCount = 3;
47 compare(lineSeries1.axisX.tickCount, 3, "set tick count");
47 compare(axisX.tickCount, 3, "set tick count");
48
48
49 lineSeries1.axisX.niceNumbersEnabled = true;
49 axisX.niceNumbersEnabled = true;
50 compare(axisX.niceNumbersEnabled, true, "nice numbers");
50 compare(axisX.niceNumbersEnabled, true, "nice numbers");
51 }
51 }
52
52
53 function test_signals() {
53 function test_signals() {
54 minChangedSpy.clear();
55 maxChangedSpy.clear();
54 axisX.min = 2;
56 axisX.min = 2;
55 compare(minChangedSpy.count, 1, "onMinChanged");
57 compare(minChangedSpy.count, 1, "onMinChanged");
56 compare(maxChangedSpy.count, 0, "onMaxChanged");
58 compare(maxChangedSpy.count, 0, "onMaxChanged");
@@ -75,13 +77,9 Rectangle {
75 id: lineSeries1
77 id: lineSeries1
76 axisX: ValueAxis {
78 axisX: ValueAxis {
77 id: axisX
79 id: axisX
78 min: 0
79 max: 10
80 }
80 }
81 axisY: ValueAxis {
81 axisY: ValueAxis {
82 id: axisY
82 id: axisY
83 min: 0
84 max: 10
85 }
83 }
86 XYPoint { x: -1; y: -1 }
84 XYPoint { x: -1; y: -1 }
87 XYPoint { x: 0; y: 0 }
85 XYPoint { x: 0; y: 0 }
@@ -57,10 +57,6 Rectangle {
57
57
58 function test_axes() {
58 function test_axes() {
59 compare(chartView.axes.length, 2);
59 compare(chartView.axes.length, 2);
60 console.log("chart.axes[0] " + chartView.axes[0]);
61 console.log("chart.axes[1] " + chartView.axes[1]);
62 console.log("lineSeries.axisX " + lineSeries.axisX);
63 console.log("lineSeries.axisY " + lineSeries.axisY);
64 verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX);
60 verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX);
65 verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY);
61 verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY);
66 verify(lineSeries.axisX == splineSeries.axisX);
62 verify(lineSeries.axisX == splineSeries.axisX);
General Comments 0
You need to be logged in to leave comments. Login now