How to create a grid with back and forth navigation in QML for IOS - ios

I'm new to QML Development. I would like to create a grid 10x2. When an element inside the grid is clicked, it takes me to the next page and show a back arrow button on toolbar to bring me back to the main grid page.
The result I'm searching for is something like this.

You can you the visible poperty of the element as follows:
Item {
id: menu
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
Component {
id: delegate
Rectangle {
id: wrapper
width:
height:
MouseArea {
anchors.fill: parent
onClicked: {
gView.currentIndex = index;
goAway();
}
}
}
}
GridView {
id: gView
anchors.fill: parent
model: model // your model
delegate: delegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
clip: true
}
function goAway() {
gView.visible = false;
arrow.visible = true;
}
function comeBack() {
gView.visible = true;
arrow.visible = false;
}
Image {
id: arrow
source: //your arrow image source
visible:false
anchors {
top: parent.top
left: parent.left
leftMargin: 20
}
MouseArea {
anchors.fill: parent
onClicked: comeBack()
}
}
You can edit it according to your needs.

Related

How can I hide/show a data that in a series? (highchart)

I know how to hide a whole series,but I have no idea about how to hide a specific data in a series. here is part of my option:
series: [
{
data: [
{ x: 35, y: 35, z: 50.8, name: "A" ,visible:false},
{ x: 25, y: 75, z: 50.8, name: "B" },
{ x: 45, y: 55, z: 50.8, name: "C", color: "red" }
]
}
mydemo
visible:false is half works , the background is disappeared but the datalabel is still there , I want hide it , and no user interaction.
and I want tigger hide/show on a bubble click like this:
const onClickBubble = event => {
let currentPointName = event.point.name;
console.log(chartRef.current.chart.series[0].options.data);
option.series[0].data.forEach(element => {
if (currentPointName === element.name) {
element.color = "green";
} else {
//hide other bubble here
element.visible = false;
}
});
let NewOptoin = Object.assign({}, option);
setOption(NewOptoin);
};
so this :
events: {
load: function(){
var point = this.series[0].points[0];
['graphic', 'dataLabel'].forEach(function (key) {
if (point[key]) {
point[key].hide();
}
});
}
}
there is no series[x].points in chart option. so this way may not work for me.
You can hide a point in the load event:
chart: {
events: {
load: function(){
var point = this.series[0].points[0];
['graphic', 'dataLabel'].forEach(function (key) {
if (point[key]) {
point[key].hide();
}
});
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/6m4e8x0y/4805/
API Reference:
https://api.highcharts.com/class-reference/Highcharts.SVGElement#hide
https://api.highcharts.com/highcharts/chart.events.load

How to show the container in a nested treemap?

I have a treemap made of
a big container
with an element
with an element
with an element which is itself made of
an element
an element
another big container
Highcharts.chart('container', {
series: [{
type: "treemap",
animation: false,
data: [
// first big category
{
id: 'B',
name: 'B'
},
{
name: 'Anne',
parent: 'B',
value: 4
}, {
name: 'Peter',
parent: 'B',
value: 1
},
// below is a member of forst big category, but with sub-categories
{
name: 'aaa container',
parent: 'B',
id: 'aaa'
}, {
name: 'Anneinaaa',
parent: 'aaa',
value: 1
}, {
name: 'Rickinaaa',
parent: 'aaa',
value: 3
},
// second big category
{
name: 'Susanne',
parent: 'Kiwi',
value: 2,
color: '#9EDE00'
}
]
}],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<div id="container"></div>
I would like to highlight the fact that there is a container for Rickinaaa and Anneinaaa, with a description.
Right now Rickinaaa and Anneinaaa are at the same level as Anne and Peter, despite the fact that it is their container (the one I do not know how to show) which should be at their level.
An example from ZingCharts which shows this multilayer presentation:
It is much easier to see the box-in-a-box structure.
Is there a way to achieve this in Highcharts? Specifically, how could I have a visible container labelled aaa container which would encompass the rectangles Rickinaaa and Anneinaaa
It can be done by using custom positioning algorithm for treemap. The process is described here: https://www.highcharts.com/docs/chart-and-series-types/treemap (ADD YOUR OWN ALGORITHM section).
I created simplified algorithm for demo purposes (some values are hardcoded):
// Custom positioning algorithm
function myFunction(parent, children) {
childrenAreas = [];
Highcharts.each(children, function(child) {
// Do some calculations
var newLeaf = null;
if (child.id === 'A') {
newLeaf = {
x: 0,
y: 0,
width: 50,
height: 50
};
} else if (child.id === 'B') {
newLeaf = {
x: 50,
y: 0,
width: 50,
height: 50
};
} else if (child.name === 'Rick') {
newLeaf = {
x: parent.x + 10,
y: parent.y + 10,
width: parent.width - 20,
height: (parent.height - 20) / 2
}
} else if (child.name === 'Peter') {
newLeaf = {
x: parent.x + 10,
y: parent.y + 30,
width: parent.width - 20,
height: (parent.height - 20) / 2
}
} else if (child.name === 'Anne') {
newLeaf = {
x: parent.x + 10,
y: 10,
width: parent.width - 20,
height: parent.height - 20
}
}
if (newLeaf) {
childrenAreas.push(newLeaf);
}
});
return childrenAreas;
};
Highcharts.seriesTypes.treemap.prototype.myCustomAlgorithm = myFunction;
By default Highcharts assigns color fill attribute only for the nodes of the Highest level - all other nodes have it set to none. It can be changed manually via CSS:
.highcharts-internal-node {
fill: #bada55
}
I also did a small change in the core code so that parent levels are drawn underneath the child ones:
(function(H) {
var grep = H.grep,
each = H.each,
seriesTypes = H.seriesTypes;
H.seriesTypes.treemap.prototype.drawPoints = function() {
var series = this,
points = grep(series.points, function(n) {
return n.node.visible;
});
each(points, function(point) {
var groupKey = 'level-group-' + point.node.levelDynamic;
if (!series[groupKey]) {
series[groupKey] = series.chart.renderer.g(groupKey)
.attr({
// CHANGED FROM: zIndex: 1000 - point.node.levelDynamic
zIndex: 1000 + point.node.levelDynamic // #todo Set the zIndex based upon the number of levels, instead of using 1000
})
.add(series.group);
}
point.group = series[groupKey];
});
// Call standard drawPoints
seriesTypes.column.prototype.drawPoints.call(this);
// If drillToNode is allowed, set a point cursor on clickables & add drillId to point
if (series.options.allowDrillToNode) {
each(points, function(point) {
if (point.graphic) {
point.drillId = series.options.interactByLeaf ? series.drillToByLeaf(point) : series.drillToByGroup(point);
}
});
}
}
})(Highcharts);
Live demo: https://jsfiddle.net/BlackLabel/wfed4jeo/

Sliding div offscreen

As soon as im clicking on the div it is moving offscreen, but the second div isn't showed.Secondaly,I want this transition to happen on click of "click to slide two happen" on both.Here is the link to the fiddle
http://jsfiddle.net/ykbgT/10110/
Any help would be great. Thanx in advance
$('.box').click(function() {
$('.box').each( function() {
if ($(this).offset().left < 0) {
$(this).css("left", "150%");
}
});
$(this).animate({
left: '-50%'
}, 500);
if ($(this).next().size() > 0) {
$(this).next().animate({
left: '50%'
}, 500);
} else {
$(this).prevAll().last().animate({
left: '50%'
}, 500);
}
});

Titanium uitableview can't scroll up with search enable (Android)

When i scroll down and release, i can't scroll up again, i have got this issue on android
My sdk version is 5.1
Here is my search,
var search = Titanium.UI.createSearchBar({
barColor: '#fb2942',
showCancel: true,
top: 0,
hintText: 'Search....',
});
table.search = search;
table.filterAttribute = 'title';
if (OS_ANDROID) {
table.searchHidden = false;
} else {
table.searchHidden = false;
}
table.separatorColor = "#ddd";
search.addEventListener('change', function(e) {
e.value;
});
search.addEventListener('return', function(e) {
search.blur();
});
search.addEventListener('cancel', function(e) {
search.blur();
});
And here is my tableview,
var table = Titanium.UI.createTableView({
backgroundColor: 'white',
separatorColor: "#ddd",
separatorInsets: {
left: 0,
right: 0
},
top: '8dp',
height: Ti.UI.SIZE,
});
In order to be scrollable the TableView height must be set to its default Ti.UI.FILL or a fixed/percentage width, but not Ti.UI.SIZE since that will cause it to fit its content, at which point there's nothing to scroll ;)

what is this control and how to use it in BB 10 cascades for navigation

I need to develop a bb 10 cascades app in which i need to add a control like in this image
http://subefotos.com/ver/?37868d57047746ce1ea9ca55b7637e9eo.jpg#codigos
(rounded in red color)
when i touch on second bubble, i need to show second screen ,for third bubble third screen and so on. Default screen should be displayed is first screen(first bubble high lights)
but how to do it in BB 10 cascades and what is that control called in bb 10?
Please help,
Thanks !!!
-------AM ADDED PAGE NAVIGATION HERE, REUSE THIS CODE FOR YOUR PROJECT-------------
Get sample app from my github samples for your query....
https://github.com/svmrajesh/BB-10-Cascades/tree/master/MY%20APPS/stackNavigation
1.main.qml: (first page)
import bb.cascades 1.0
NavigationPane { id: navigationPane backButtonsVisible: false peekEnabled: false
Page {
id: rootPage
Container {
background: Color.LightGray
layout: DockLayout {
}
Label {
text: "First page"
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
}
}
actions: [
ActionItem {
title: "Next page"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
var page = pageDefinition.createObject();
navigationPane.push(page);
}
attachedObjects: ComponentDefinition {
id: pageDefinition
source: "PageTwo.qml"
}
}
]
}
onPopTransitionEnded: {
page.destroy();
}
}
2.second page
import bb.cascades 1.0
Page { id: pageTwo Container { background: Color.Gray layout: DockLayout {
}
Label {
text: "Second page"
horizontalAlignment: HorizontalAlignment.Center
}
Container {
layout: StackLayout {
}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
text: qsTr("Next Page")
imageSource: "asset:///images/picture1thumb.png"
onClicked: {
// show detail page when the button is clicked
var page = getSecondPage();
console.debug("pushing detail " + page)
navigationPane.push(page);
}
property Page secondPage
function getSecondPage() {
if (! secondPage) {
secondPage = secondPageDefinition.createObject();
}
return secondPage;
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "PageTwoOne.qml"
}
]
}
Button {
text: "Previous Page"
onClicked: {
navigationPane.pop();
}
}
}
}
/* ------------- Use this Code If back button visibility is "True"-----------------
paneProperties: NavigationPaneProperties {
backButton: ActionItem {
title: "Back"
// imageSource: "asset:///back.png"
onTriggered: {
navigationPane.pop();
}
}
} */
}
3.last page
import bb.cascades 1.0
Page { id: pageTwoone
Container {
background: Color.DarkGray
layout: DockLayout {}
Label {
horizontalAlignment: HorizontalAlignment.Center
text: "Last Page"
}
Container {
layout: StackLayout {}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Home Page")
onClicked: {
// show detail page when the button is clicked
navigationPane.navigateTo(rootPage);
}
}
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Back")
onClicked: {
// show detail page when the button is clicked
navigationPane.pop();
}
}
}
}
}
------------ ADD More pages to navigate using this code----------------------------
-------------copy this code and run.. get sample app from above link if needed ------

Resources