aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/stocqt/content/StockChart.qml
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-08 12:15:03 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-08 12:15:50 +0100
commit75423185e4b03fabfeeee403f3bd9a6063078ee6 (patch)
tree6ad81ff44dda72126463fd3473be1567638b2436 /examples/quick/demos/stocqt/content/StockChart.qml
parenta2d4f1610db204e42722f20ff64716a14dc109c0 (diff)
parent3879b3f883dd66feddc190eb8bad330367a31ace (diff)
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Diffstat (limited to 'examples/quick/demos/stocqt/content/StockChart.qml')
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml29
1 files changed, 25 insertions, 4 deletions
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
index 147f513456..cd8b9f3db9 100644
--- a/examples/quick/demos/stocqt/content/StockChart.qml
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -321,11 +321,27 @@ Rectangle {
ctx.restore();
}
- onPaint: {
- if (!stockModel.ready) {
- return;
- }
+ function drawError(ctx, msg)
+ {
+ ctx.save();
+ ctx.strokeStyle = "#888888";
+ ctx.font = "24px Open Sans"
+ ctx.textAlign = "center"
+ ctx.shadowOffsetX = 4;
+ ctx.shadowOffsetY = 4;
+ ctx.shadowBlur = 1.5;
+ ctx.shadowColor = "#aaaaaa";
+ ctx.beginPath();
+ ctx.fillText(msg, (canvas.width - tickMargin) / 2,
+ (canvas.height - yGridOffset - yGridStep) / 2);
+
+ ctx.closePath();
+ ctx.stroke();
+ ctx.restore();
+ }
+
+ onPaint: {
numPoints = stockModel.indexOf(chart.startDate);
if (chart.gridSize == 0)
@@ -337,6 +353,11 @@ Rectangle {
drawBackground(ctx);
+ if (!stockModel.ready) {
+ drawError(ctx, "No data available.");
+ return;
+ }
+
var highestPrice = 0;
var highestVolume = 0;
var lowestPrice = -1;