##// 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 561 if (qobject_cast<DeclarativeChart *>(list->object)) {
562 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 565 return 0;
566 566 }
@@ -115,20 +115,20 public:
115 115 int count();
116 116 void setDropShadowEnabled(bool enabled);
117 117 bool dropShadowEnabled();
118
119 // Margins & plotArea
118 120 qreal topMargin();
119 121 qreal bottomMargin();
120 122 qreal leftMargin();
121 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 124 DeclarativeMargins *minimumMargins() { return m_margins; }
127
128 125 Q_REVISION(2) DeclarativeMargins *margins() { return m_margins; }
129 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 132 QDeclarativeListProperty<QAbstractAxis> axes();
133 133 static void axesAppendFunc(QDeclarativeListProperty<QAbstractAxis> *list, QAbstractAxis *element);
134 134 static int axesCountFunc(QDeclarativeListProperty<QAbstractAxis> *list);
@@ -62,7 +62,7 Rectangle {
62 62 // Legend font
63 63 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
64 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 66 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
67 67 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
68 68 verify(chartView.legend.font.pixelSize > 0
@@ -73,6 +73,7 Rectangle {
73 73 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
74 74 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
75 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 58 // Legend font
59 59 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
60 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 62 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
63 63 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
64 64 verify(chartView.legend.font.pixelSize > 0
@@ -32,10 +32,10 Rectangle {
32 32 when: windowShown
33 33
34 34 function test_defaultPropertyValues() {
35 compare(lineSeries1.axisX.min, 0, "AxisX min");
36 compare(lineSeries1.axisX.max, 10, "AxisX max");
37 compare(lineSeries1.axisY.min, 0, "AxisY min");
38 compare(lineSeries1.axisY.max, 10, "AxisY max");
35 verify(axisX.min < 0, "AxisX min");
36 verify(axisX.max > 0, "AxisX max");
37 verify(axisY.min < 0, "AxisY min");
38 verify(axisY.max > 0, "AxisY max");
39 39 verify(axisX.tickCount > 0, "AxisX tick count");
40 40 verify(axisY.tickCount > 0, "AxisX tick count");
41 41 compare(axisX.niceNumbersEnabled, false, "nice numbers");
@@ -43,14 +43,16 Rectangle {
43 43 }
44 44
45 45 function test_modifyProperties() {
46 lineSeries1.axisX.tickCount = 3;
47 compare(lineSeries1.axisX.tickCount, 3, "set tick count");
46 axisX.tickCount = 3;
47 compare(axisX.tickCount, 3, "set tick count");
48 48
49 lineSeries1.axisX.niceNumbersEnabled = true;
49 axisX.niceNumbersEnabled = true;
50 50 compare(axisX.niceNumbersEnabled, true, "nice numbers");
51 51 }
52 52
53 53 function test_signals() {
54 minChangedSpy.clear();
55 maxChangedSpy.clear();
54 56 axisX.min = 2;
55 57 compare(minChangedSpy.count, 1, "onMinChanged");
56 58 compare(maxChangedSpy.count, 0, "onMaxChanged");
@@ -75,13 +77,9 Rectangle {
75 77 id: lineSeries1
76 78 axisX: ValueAxis {
77 79 id: axisX
78 min: 0
79 max: 10
80 80 }
81 81 axisY: ValueAxis {
82 82 id: axisY
83 min: 0
84 max: 10
85 83 }
86 84 XYPoint { x: -1; y: -1 }
87 85 XYPoint { x: 0; y: 0 }
@@ -57,10 +57,6 Rectangle {
57 57
58 58 function test_axes() {
59 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 60 verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX);
65 61 verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY);
66 62 verify(lineSeries.axisX == splineSeries.axisX);
General Comments 0
You need to be logged in to leave comments. Login now