I know how to create and set the iOS refresh buttons in titanium but i do not know how to make them actually refresh data in tabs/windows. I have created refresh buttons for my app.js and four other tabs but it does not refresh data.
var Cloud = require('ti.cloud');
var scrollView4 = Ti.UI.createScrollView({
contentWidth: 'auto',
contentHeight: 'auto',
showVerticalScrollIndicator: true,
showHorizontalScrollIndicator: true
});
Titanium.UI.currentWindow.add(scrollView4);
var currentWin4 = Titanium.UI.currentWindow;
var refreshBtn = Titanium.UI.createButton({
Color: 'black',
systemButton : Titanium.UI.iPhone.SystemButton.REFRESH
});
currentWin4.setLeftNavButton(refreshBtn);
currentWin4.add(refreshBtn);
var l1 = Ti.UI.createLabel({
left: 10,
top: 15,
width:'auto',
height:40,
color: '#1E90FF',
text: 'About us',
font: {
fontWeight: 'bold',
fontSize: 20
}
});
scrollView4.add(l1);
var l2 = Ti.UI.createLabel({
left:10,
top: 50,
width:'auto',
height:40,
color: '#336699',
text: 'photo sharing app',
font: {
fontSize: 13
}
});
scrollView4.add(l2);
var l3 = Ti.UI.createLabel({
left: 10,
top: 90,
width:'auto',
height:40,
color: '#336699',
text: '',
font: {
fontSize: 13
}
});
scrollView4.add(l3);
var l5 = Ti.UI.createLabel({
left: 10,
top: 170,
width:'auto',
height:40,
color: '#336699',
text: 'locate us!',
font: {
fontSize: 13
}
});
scrollView4.add(l5);
var l6 = Ti.UI.createLabel({
right: 10,
top: 250,
width:'auto',
height:40,
color: '#1E90FF',
text: 'Development & API',
font: {
fontWeight: 'bold',
fontSize: 20
}
});
scrollView4.add(l6);
var b1 = Ti.UI.createButton({
right: 10,
top: 290,
width:'auto',
height:40,
color: '#336699',
title: 'Development & API',
font: {
fontSize: 13
}
});
scrollView4.add(b1);
var l9 = Ti.UI.createLabel({
center: 0,
top: 460,
width: 'auto',
height: 40,
color: '#1E90FF',
text: 'complaints?'
});
scrollView4.add(l9);
var b2 = Ti.UI.createButton({
center: 0,
top: 500,
width:'auto',
height: 40,
color: '#336699',
title: 'talk to us'
});
scrollView4.add(b2);
var emailDialog = Titanium.UI.createEmailDialog({toRecipients:['zyaine#gmail.com']});
emailDialog.Subject = ('');
emailDialog.messageBody = '';
b2.addEventListener('click',function(e)
{
emailDialog.open();
});
emailDialog.addEventListener('complete',function(e)
{
if (e.result == emailDialog.SENT)
{
alert("message sent");
}
else
{
alert("message not sent");
}
You have to implement an event handler
refreshBtn.addEventHandler('click', function(e) {
//Add code here that will fetch row data and redraw.
}
Without having more info it is tough to answer more specifically
I don't see anything in your code that represents any data that could be refreshed... in general, you need a "click" event handler for the button.
Inside the click handler, you can for example use the setData() method on a TableView object to set data for the TableView.
Or for a WebView, you could reload it's URL.
If you want to repaint the Window/View I'm afraid there is no dedicated method for that. You could try if applyProperties() causes a repaint. But I'm not sure why one would want to do that in the first place.
It would be helpful if you tell us more about the data you want to refresh. What kind of data, where does it come from etc.
Related
We are trying to develop a progress bar in which we have to align a text on top of button. We tried using different layouts but its not coming. Can some suggest a way to do it using CSS if possible. Attaching the example here.
CSS should solve your problem, this is a bit hard-coded and won't work as a generic solution but you can start from here:
First let's create a panel with progress bars and a button between them:
Ext.create('Ext.panel.Panel', {
renderTo: document.body,
height: 100,
layout: {
type: 'hbox',
align: 'middle'
},
defaults: {
margin: 2
},
items: [{
xtype: 'progressbar',
style: {
borderRadius: '5px'
},
height: 10,
width: 200,
text: ' ',
value: 1
}, {
xtype: 'container',
cls: 'btnWrapper',
items: [{
xtype: 'button',
height: 30,
cls: 'fa fa-check',
style: {
color: 'white'
}
}]
}, {
xtype: 'progressbar',
style: {
borderRadius: '5px'
},
height: 10,
text: ' ',
width: 200
}]
});
And here is the CSS to take care of the rest:
<style>
.btnWrapper:before {
content: 'BASICS';
font-weight: bold;
position: absolute;
top: -20px;
left: -10px;
width: 100%;
color: orange;
text-align: center;
}
.btnWrapper .x-btn {
border-radius: 30px;
}
</style>
Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/21n5
I'm trying to customize vAxis gridlines become dash. But, it didn't run very well, everytime I change stroke-dasharray value in css it still blur.
please, is someone know how to change vAxis gridline into dash?
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
var options = {
width:'100%',
focusTarget: 'category',
backgroundColor: 'transparent',
chartArea: {
left: 20,
top: 10,
width: '100%',
height: '70%'
},
bar: {
groupWidth: '70%'
},
hAxis: {
textStyle: {
fontSize: 9,
color:'#929496'
}
},
vAxis: {
baselineColor: '#e6e6e6',
gridlines: {
color: '#e6e6e6',
count: 9
},
textStyle: {
fontSize: 9,
color:'#929496'
}
},
legend: {
position: 'bottom',
textStyle: {
fontSize: 9,
color:'#929496'
}
},
animation: {
duration: 300,
easing: 'out',
startup: true
}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
#chart_div svg > g:nth-child(3) > g:nth-child(2) > g:first-child rect{
fill: none;
stroke-width: 1;
stroke: #ddd;
stroke-dasharray: 5 5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
I'm using Google Charts.
I'm trying to display 15 stores and the number of clicks on each one.
Now that's is working perfectly.
My issue here is in the hAxis. As you can see the stores' names are incomplete, which is fine, but when i hover on an incomplete name, the tooltip is showing me an empty yellow box as shown in the picture below.
If i select the context of this tooltip, then i can read the full name:
My question is:
Is it possible to change the text color in this tooltip in order to read it?
Thanks.
to modify the axis tooltip, you can modify the following css classes...
.goog-tooltip {
background-color: cyan;
color: magenta;
font-weight: bold;
}
.goog-tooltip > div {
background-color: lime !important;
}
see following working snippet...
google.charts.load('current', {
callback: drawChart,
packages: ['corechart']
});
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Q1');
data.addColumn('number', 'Q2');
data.addColumn('number', 'Q3');
data.addColumn('number', 'Q4');
data.addRow(['January 2016', 500, 100, 1200, 1000]);
data.addRow(['February 2016', 500, 100, 1975, 1000]);
data.addRow(['March 2016', 500, 100, 1200, 1000]);
data.addRow(['April 2016', 500, 100, 1200, 1000]);
// find v-axis max value
var vAxisMax = null;
for (var i = 1; i < data.getNumberOfColumns(); i++) {
var range = data.getColumnRange(i);
vAxisMax = vAxisMax || Math.ceil(range.max / 1000) * 1000;
vAxisMax = Math.max(vAxisMax, Math.ceil(range.max / 1000) * 1000);
}
// add buffer for annotation
vAxisMax += 400;
var options = {
backgroundColor: '#000000',
chartArea: {
top: 12,
bottom: 24,
left: 72
},
legend: {
position: 'none'
},
colors: ['#9427E0'],
hAxis: {
slantedText: true,
textStyle: {
color: '#ffffff'
}
},
vAxis: {
title: 'Amount',
viewWindow: {
max: vAxisMax
}
},
bar: {
groupWidth: '90%'
},
annotations: {
style: 'point',
alwaysOutside: true
},
width: 1100,
height: 300
};
var view = new google.visualization.DataView(data);
view.setColumns([
0,
1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" },
2, { calc: "stringify", sourceColumn: 2, type: "string", role: "annotation" },
3, { calc: "stringify", sourceColumn: 3, type: "string", role: "annotation" },
4, { calc: "stringify", sourceColumn: 4, type: "string", role: "annotation" }
]);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(view, options);
}
.goog-tooltip {
background-color: cyan;
color: magenta;
font-weight: bold;
}
.goog-tooltip > div {
background-color: lime !important;
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
Try slantedTextAngle
hAxis: {direction:1, slantedText:true, slantedTextAngle:90 },
I have updated FabricJS version 1.5 to 1.6(beta), then the text shadow effects does not work now. Here is my function. How to fix this issue?
$('#text-shadow-set').change(function (){
if(isText()) {
if(this.checked) {
var tmp = $('#text-shadow-offset-slider').slider('option','value');
var shadVal = (tmp==''||tmp==0) ? 20 : tmp;
currentElement.setShadow({
color: '#000',
blur: 5,
offsetX: shadVal,
offsetY: shadVal
});
canvas.renderAll();
} else {
currentElement.setShadow(null);
canvas.renderAll();
}
}
});
Text and shadows seem to work fine. Check the demo below:
var text = new fabric.Text('Text with Shadow', {
left: 50,
top: 150,
fill: 'red',
strokeWidth: 1,
stroke: 'black',
});
text.setShadow({
color: 'black',
blur: 5,
offsetX: 10,
offsetY: 10,
opacity: 0.5,
});
canvas.add(text);
canvas.renderAll();
DEMO
var canvas = new fabric.Canvas('c');
var text = new fabric.Text('Text with Shadow', {
left: 50,
top: 150,
fill: 'red',
strokeWidth: 1,
stroke: 'black',
});
text.setShadow({
color: 'black',
blur: 5,
offsetX: 10,
offsetY: 10,
opacity: 0.5,
});
canvas.add(text);
canvas.renderAll();
canvas {
border: 1px solid #f00;
margin: 0px;
display: block;
}
<script src="https://rawgit.com/fabricjs/fabric.js/master/dist/fabric.min.js"></script>
<canvas id="c" width="400" height="400"></canvas>
I now have a google chart like this bellow picture
Now I want to move the tooltip to the top of chart (dont care the position of my mouse).
How can I do it.
Here is my code :
var chartData = new google.visualization.DataTable();
chartData.addColumn('string', 'Time');
chartData.addColumn('number', 'Average Score');
chartData.addColumn({ 'type': 'string', 'role': 'tooltip', 'p': { 'html': true } });
chartData.addRows(data);
var options = {
chartArea: { left: 0, top: 100, width: "100%", height: "100%" },
title: '',
opacity: 100,
backgroundColor : {fill: '#000'},
hAxis: {
textPosition: 'none',
titleTextStyle: {color: '#333'},
titleTextStyle: {color: '#2902A3'},
},
vAxis: {
textPosition: 'none',
opacity: 100,
minValue: 0,
gridlines: { color: '#0D2B56', count: 10 },
baselineColor: 'white',
},
series:{
0:{
color: '#3C93FF',
areaOpacity: '0.68'
}
},
crosshair: {
orientation: 'vertical',
trigger: 'focus',
color: '#fff'
},
legend: 'none',
tooltip: {isHtml: true},
};
google.load("visualization", "1", { packages: ["corechart"] });
var chart = new google.visualization.AreaChart(document.getElementById('chart'));
chart.draw(chartData, options);
I also use this function to create tooltip's content
var createToolTip = function (name, value) {
return '<div class="googletooltip" ><span>' + name + ':</span><span style="padding-left:20px" >' + value + '</span></div>';
}
and this style also
.googletooltip{
color:#fff;
border-style: solid;
border-width: 2px;
border-color: #3882C4;
background: #000;
padding:2px 15px 2px 15px;
font-weight: bold;
}
Thank a lot
Try adding a top property and a position property for the .googletooltip class. If not, try using the margin property if the other properties are not working. Work around these three properties and see if you will be able to move tooltip up. Let me know if it still isn't working.
.googletooltip{
color:#fff;
border-style: solid;
border-width: 2px;
border-color: #3882C4;
background: #000;
padding:2px 15px 2px 15px;
font-weight: bold;
}
Where are you calling createToolTip function? Is it called while generating data chartData.addRows(data);?
Ref: check how createCustomHTMLContent function is used # https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#custom_html_content