Ext Js show a text above a button element - css

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

Related

ApexCharts polarArea — background colour for rings

I'm trying to give a background colour to my ApexCharts polarArea chart (I want the areas marked by red dots in the image to be grey/white):
I can't find a way to do this. I've tried adding fill to the various options, but nothing. I thought it might be possible with polygons like the radar chart, but no.
The closest I have come is by adding a CSS class to the chart on the containing Vue component:
<Chart class="chart" :myValues='this.myValues' :key="componentKey" />
.chart {
width: 320px;
height: 320px;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
border-radius: 50%;
margin: auto;
padding-top: 3px;
padding-right: 4px;
}
But annoyingly it's not centred on the chart origin and even with pixel precise increments to padding it's not quite right! Also, if possible I'd like alternating colours for each of the rings, like is possible with the radar chart.
My full chart Vue component:
<template>
<div class="polarChart">
<apexcharts height="360" type="polarArea" :options="chartOptions" :series="series"></apexcharts>
</div>
</template>
<style scoped>
.polarChart {
align-items: center;
}
</style>
<script>
import VueApexCharts from 'vue-apexcharts'
export default {
name: 'Chart',
components: {
apexcharts: VueApexCharts,
},
props: ['myValues'],
data: function() {
return {
series: this.myValues,
plotOptions: {
polarArea: {
dataLabels: {
offset: 30
},
}
},
chartOptions: {
labels: ['A', 'B', 'C', 'D', 'E', 'F'],
colors:['#403d39', '#ffbe0b', '#00b4d8', '#e73265', '#90be6d', '#ada7c9'],
legend: {
show: false
},
yaxis: {
max: 100,
show: false
},
xaxis: {
categories: ['A.', 'B.', 'C.', 'D.', 'E.', 'F.']
},
dataLabels: {
enabled: true,
formatter: function (val, opts) {
return Math.round(opts.w.globals.series[opts.seriesIndex]) + "% " + opts.w.globals.labels[opts.seriesIndex]
},
background: {
enabled: true,
borderRadius:2,
},
style: {
colors: ['#403d39', '#ffbe0b', '#00b4d8', '#e73265', '#90be6d', '#ada7c9'],
}
},
tooltip: {
// enabled: false
},
chart: {
type: 'polarArea',
},
stroke: {
colors: ['#fff']
},
fill: {
opacity: 1
},
responsive: [{
breakpoint: 480,
options: {
chart: {
width: '100%'
},
legend: {
position: 'bottom'
}
}
}]
},
}
},
methods: {
addData(){
this.updateChart();
},
updateChart() {
this.series = [{
data: this.freshnessValues
}]
}
},
}
</script>

extjs shrink area between displayfields (labels and values)

how do I shrink the area between these displayfields?
I've tried moving padding... margins... nothing seems to work. When I do end up getting the labels the way they should look (with very little space)... then the values are not aligned next to the label correctly.
this is how I have it setup.
layout: 'column',
defaults: {
layout: 'form',
xtype: 'container',
//defaultType: 'textfield',
style: 'width: 50%'
},
items: [{
items: [
{
xtype: 'displayfield',
fieldLabel: 'Client',
bind: {
value: '{selectedClientListModel.ClientName}'
},
fieldStyle: 'color: #ff0000; padding: 0px; margin: 0px;',
labelStyle: 'color: #ff0000; padding: 0px; margin: -5px;'
//ui: 'dark'
},
{
xtype: 'displayfield',
fieldLabel: 'Acct Desc',
itemId: 'textfieldAcctDesc',
bind: {
value: '{selectedManager.AcctShortCode}'
},
fieldStyle: 'color: #ff0000; line-height: 1; padding: 0px; margin: 0px;',
labelStyle: 'color: #ff0000; line-height: 1; padding: 0px; margin: -15px;'
},
{
xtype: 'displayfield',
fieldLabel: 'Acct Num',
itemId: 'textfieldAcctNum',
bind: {
value: '{selectedManager.AcctNum}'
},
fieldStyle: 'color: #ff0000; line-height: 1; padding: 0px; margin: 0px;',
labelStyle: 'color: #ff0000; line-height: 1; padding: 0px; margin: -5px;'
}
]
}, {
displayfields are intended to align neatly with other form fields - which have spacious borders around their input fields. For that reason, displayfields have the same height, they even haven't got a different SCSS variable for displayfield height.
Furthermore, from the CSS classes available, the fieldLabel cannot distinguish between being a displayfield's label and another field's label. Because of that, you will have to give your displayfield at least a custom userCls, or else all your regular form fields will look ridiculous.
Then you can go and add some CSS like this:
.myUserCls,
.myUserCls .x-form-item-label,
.myUserCls .x-form-display-field
{
line-height:16px;
min-height:16px;
margin-bottom:0;
margin-top:0;
padding-top:0;
}
I have made you a fiddle.

Adding a colored border (not shadow) to the label text on a Highcharts treemap

I would like the label text on my Highcharts treemap to be white with a black border, so that it is consistent and clearly visible on all colors. Is this possible? I have played with the textShadow options, and it looks okay (although not great) in Chrome, but it looks very unprofessional in Internet Explorer. See the fiddle here:
https://jsfiddle.net/k1hohozg/4/
$(function () {
$('#container').highcharts({
title: "",
series: [{
type: "treemap",
data: [
{
name: 'Name One',
value: 20,
color: "#FFFF00"
}, {
name: 'Name Two',
value: 20,
color: '#000099',
}, {
name: 'Name Three',
value: 1,
color: '#007799',
}, {
name: 'Name Four',
value: 1,
color: '#FFCC00',
}
],
levels: [{
level: 1,
dataLabels: {
enabled: true,
align: 'center',
style: {
fontSize: '20px',
color: '#FFFFFF',
textShadow: "0 0 3px #000, 0 0 3px #000",
}
},
}],
}],
});
})
I do not want to use the "contrast" option because I need all the text to look the same, hence white with a black border. What is the best way to make this look better in all standard browsers?
Thanks!
There is no default Highcharts way to deal with IE rendering poorly text-shadow. It is possible to set useHTML to true and add multiple labels that will be imitating shadow. (Looks fine in Chrome, Firefox and IE11).
Example: http://jsfiddle.net/yzLavxc9/2/
....
dataLabels: {
useHTML: true,
formatter: function () {
return '<div class=dataLabelContainer><div style="position: absolute; top: -1px; left: 1px; color: #000;">'+this.key+'</div><div style="position: absolute; top: 1px; left: 1px; color: #000;">'+this.key+'</div><div style="position: absolute; top: 1px; left: -1px; color: #000;">'+this.key+'</div><div style="position: absolute; top: -1px; left: -1px; color: #000;">'+this.key+'</div><div style="position: absolute; color: #fff;">'+this.key+'</div></div><div style="color: #fff;">'+this.key+'</div></div>';
},
enabled: true,
align: 'center',
style: {
fontSize: '20px',
....
I think this is not possible with the textShadow attribute wich is not well interpreted with IE. However you can add a background on your labels to be more visible :
$(function() {
$('#container').highcharts({
title: "",
series: [{
type: "treemap",
data: [{
name: 'Name One',
value: 1,
color: "#FFFF00"
}, {
name: 'Name Two',
value: 1,
color: '#000099',
}],
levels: [{
level: 1,
dataLabels: {
enabled: true,
align: 'center',
borderRadius: 5,
backgroundColor: 'rgba(255, 255, 255, 1)',
style: {
fontSize: '20px',
color: '#000',
}
},
}],
}],
});
})
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<div id="container"></div>
You can inspire yourself from the documentation:
http://api.highcharts.com/highcharts#plotOptions.area.dataLabels.backgroundColor

ExtJS 4.2.3 floating image between window header and body

Here is the output I require!
Here is how I try to achieve this:
win = Ext.create('Ext.window.Window', {
height: 650,
width: 500,
layout: 'fit',
border: false,
bodyPadding: 10,
modal:true,
itemId:'serviceCallWindow',
header: {
cls: 'n-service-call-window-header',
height: 80,
items:[{
xtype: 'component',
floating: true,
autoShow: true,
shadow: false,
focusOnToFront:false,
defaultAlign: 't',
autoEl: {
tag: 'img',
src: NG.serverMapPath('~/resources/images/support/support_icon.png')
},
componentCls: 'n-service-call-support-icon'
}]
},
items: [{
xtype: 'servicecall',
border: false,
bodyPadding: 10
}]
});
The challenge is to get the service call icon between the window header and body.
How can I achieve this?
This is achievable through manipulating CSS and the various layouts. You would perhaps also need to get rid of the header and actually make your own "close" button which would fire the windows close method.
such as below:
Ext.application({
name: 'Fiddle',
launch: function() {
win = Ext.create('Ext.window.Window', {
height: 300,
width: 500,
border: false,
bodyPadding: 10,
header: false,
modal: true,
layout: 'vbox',
itemId: 'serviceCallWindow',
items: [{
xtype: 'container',
/*layout: {
type: 'hbox',
pack: 'center'
},*/
width: '100%',
items: [{
xtype: 'image',
cls: 'testLogo',
style: {
margin: '0 auto',
width: '50px',
display: 'block'
},
src: 'http://placehold.it/50x50'
}, {
xtype: 'button',
cls: 'testClose',
style: {
top: 0,
right: 0,
position: 'absolute'
},
icon: 'http://placehold.it/20x20',
listeners: {
click: function() {
win.close();
}
}
}],
}, {
xtype: 'container',
border: false,
bodyPadding: 10,
html: 'this is the content of another container'
}]
});
win.show();
}
});
Demo: https://fiddle.sencha.com/#fiddle/g6t

scaling images to screen dimension sencha touch2

this is my code:
Code:
{ xtype: 'tabpanel',
docked: 'top',
height: 752,
width: '100%',
activeItem: 1,
items: [
{
xtype: 'container',
title: 'MyCar',
items: [
{
xtype: 'container',
maxWidth: '100%',
width: '100%',
items: [
{
xtype: 'image',
docked: 'top',
height: 407,
html: '',
id: 'imgCar',
padding: '0 0 0 510',
style: 'margin: 0px auto; width: 50%;background-size: auto;',
src: 'http://localhost/car.jpg'
}
]
},
{
xtype: 'dataview',
height: 297,
html: ' <table id="tableConsumptions"> <tr> <td id="consumptionsCol">val</td></tr> </table>',
width: '100%',
itemTpl: [
''
]
}
]
},
{
I have an image container, and I would like to adapt the image dimension to the screen dimension, scaling it.
How is it possible?
Thanks in advance.
You can try using this function to fetch the height and width of the Viewport.
Ext.viewport.getWindowHeight( );
Ext.viewport.getWindowWidth( );
for those who might stumbled on this...
most important thing is the parent container of the image component need to be "fit" (card might also do) and we set the background-size styling of the image component to 100% (for width and height)
{
xtype: 'tabpanel',
docked: 'top',
height: 752,
width: '100%',
activeItem: 1,
items: [
{
xtype: 'container',
title: 'MyCar',
items: [
{
xtype: 'container',
layout: 'fit', //supposedly when we want our image to be the same size as its container without specifying width and height, we use this and set the background-size style of the image to 100% (for both width and height)
maxWidth: '100%',
width: '100%',
items: [
{
xtype: 'image',
docked: 'top',
height: 407,
html: '',
id: 'imgCar',
style: 'background-size: 100% 100% !important;', //the most important key is backgeound-size styling for the image as it will be set as background of a div (unless we use mode: 'img' config)
src: 'http://localhost/car.jpg'
}
]
},
{
xtype: 'dataview',
height: 297,
html: ' <table id="tableConsumptions"> <tr> <td id="consumptionsCol">val</td></tr> </table>',
width: '100%',
itemTpl: [
''
]
}
]
}
]
}

Resources