Dynamically set color of line/spline in Nativescript-UI-Chart? - angular2-nativescript

I need to match the color of each line in a chart to the color given by the object providing the data. The meter.color variable holds the color I need to use.
<StackLayout class="container" orientation="vertical">
<Label class="title" [text]="widget.settings.title" horizontalAlignment="center"></Label>
<RadCartesianChart class="chart" tkExampleTitle tkToggleNavButton>
<ng-container *ngFor="let meter of readings$ | async">
<ng-container [ngSwitch]="meter.type">
<LineSeries tkCartesianSeries seriesName="Line" *ngSwitchCase="'line'" [legendTitle]="meter.name + ' - ' + meter.unit"
[items]="meter.data" stackMode="Stack" categoryProperty="timestamp" valueProperty="value">
<Palette tkCartesianPalette seriesName="Line">
<PaletteEntry tkCartesianPaletteEntry [strokeColor]="meter.color"></PaletteEntry>
</Palette>
</LineSeries>
<SplineSeries tkCartesianSeries seriesName="Spline" *ngSwitchCase="'spline'" [legendTitle]="meter.name"
[items]="meter.data" stackMode="Stack" categoryProperty="timestamp" valueProperty="value">
<Palette tkCartesianPalette seriesName="Spline">
<PaletteEntry tkCartesianPaletteEntry [strokeColor]="meter.color"></PaletteEntry>
</Palette>
</SplineSeries>
</ng-container>
<RadLegendView tkCartesianLegend position="Top" title="Series" enableSelection="true"></RadLegendView>
<RadCartesianChartGrid tkCartesianGrid horizontalLinesVisible="true" verticalStrokeColor="#804d0026"></RadCartesianChartGrid>
<LinearAxis tkCartesianVerticalAxis horizontalLocation="Left" android:labelFormat="%.0f"></LinearAxis>
<DateTimeContinuousAxis tkCartesianHorizontalAxis dateFormat="hh:mm" [minimum]="backwardHour" [maximum]="forwardHour"
majorStep="Hour" labelFitMode="Rotate"></DateTimeContinuousAxis>
</ng-container>
</RadCartesianChart>
</StackLayout>
At the moment the line gets one color and the spline get another. But if i have more than two lines or splines all lines get the same color and all splines also get the same color. It seems that the last line added sets the color of both lines, the same goes for the spline.

I found a solution to my problem, i added property binding to seriesName on both the LineSeries and to the PaletteEntry witch matches each line dynamically to a ID.
Changes in my code:
<LineSeries tkCartesianSeries [seriesName]="meter.id" *ngSwitchCase="'line'" [legendTitle]="meter.name + ' - ' + register.unit" [items]="register.data" stackMode="Stack" categoryProperty="timestamp" valueProperty="value">
<Palette tkCartesianPalette [seriesName]="meter.id">
<PaletteEntry tkCartesianPaletteEntry [strokeColor]="meter.color"></PaletteEntry>
</Palette>
</LineSeries>

Related

Repeat row with only four columns in html table using angular 4

For Ex. I have an arraylike this cids:Array=[{Id:1},{Id:2},{Id:3},{Id:4},{Id:5},{Id:6},{Id:7}---------etc..]
I want output as :
1 2 3 4
5 6 7 8
9
Using *ngFor in angular 4
One way is to convert your arrray[] in array[][4]. And then you will be able to use an imbricated ngFor (ngFor in another ngFor)
Pseudo code :
ngFor* {
ngFor* {
print value;
insert a space;
}
Insert a return line;
}
<span *ngFor="let cid of cids">
{{cid.Id}}
<br *ngIf="(cid.Id)%4==0" />
</span>

ionic 2 ion-grid / ion-row / ion-col not working when used as a attribute to div

<ion-grid no-padding>
<ion-row>
<ion-col>col 1</ion-col>
<ion-col>col 2</ion-col>
<ion-col>col 3</ion-col>
</ion-row>
</ion-grid>
Above code works good, its respective styles are applied, but, below one doesn't work.
<div ion-grid>
<div ion-row>
<div ion-col>col 1 div</div>
<div ion-col>col 2 div</div>
</div>
</div>
When I tried to put it as attributes, styles are not applied for grid, I get something similar to
col 1 div
col 2 div
expected result: col 1 div col 2 div
What am I doing wrong?
ref: http://ionicframework.com/docs/v2/api/components/grid/Grid/#grid-size

Doing an Access Query with PS Script over VB and writing output in HTA Textbox

I am new to PowerShell and got the following Task.
I have to Create a HTA GUI where you can write the Name to search for in the Access Query.
The VB Script in the HTA File starts the PS Script and passes the Parameter of the user Input in the HTA TextBox. After that the PowerShell Script does a Access Query with the user Input to get some results. These results should somehow get back to the VB/HTA File so it can Output every single result in an other TextBox.
Is this even possible to do? If yes, i would appreciate some solution ideas.
EDIT:
VB/HTA
VB/HTA
Wrong Format, should be like a table
You have strLine in the HTA code that reads the text file. Your code is reading the text file and taking 1 line and putting it in a text input box. In order to show the results as a table you need to create the table HTML and pass that HTML to a div element.
strLine = "<table>"
Do While Not strLines.AtEndOfStream
strLine = strLine & "<tr><td>" & strLines.ReadLine() & "</td></tr>"
Loop
strLine = strLine & "</table>"
Weiterleitung_div.innerHTML = strLine
You will need to change Weiterleitung_id.value = strLine and instead pass the strLine HTML to a element in the body. Add to the body and then
Yes it is possible. Try the code below with an access database that has 3 fields first_name, last_name, email
Save the file as Employees.mdb (you can use .accdb but you'll have to change the name in code) MAKE SURE THE ACCESS FILE IS IN THE SAME FOLDER AS THE HTA.
I copied in some data from www.mockaroo.com to test it out (I don't get paid to say that it's just very useful)
This is a very basic example but it is possible to create a nicer GUI in an HTA than in Access.
<title>Employee Directory</title>
<head>
<HTA:APPLICATION
ID="EMPDIR"
APPLICATIONNAME="Employee Directory"
SINGLEINSTANCE="YES"
>
<!-- makes the hta run using IE9 otherwise it runs as IE5 or 6. You can change this to edge -->
<meta http-equiv="x-ua-compatible" content="IE=9"/>
<style>
body {font-family:arial; background:#efefef; color:#333}
</style>
<script language="vbscript">
' ///// this creates the connection when the file is first run.
' //// get the current path if the database file is in the same folder as the hta file. if it's not then enter the full path manually below
Set objFSO = CreateObject("Scripting.FileSystemObject")
curDir = objFSO.GetAbsolutePathName(".") & "\"
Dim oCon: Set oCon = CreateObject("ADODB.Connection")
Dim oRs: Set oRs = CreateObject("ADODB.Recordset")
strCon = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq="& curDir & "Employees.mdb;"
oCon.ConnectionString= strCon
sub getEmployeeList
' gets a list of employees based on the value in the searchbox input.
oCon.open
strSQL = "SELECT * FROM Employees WHERE (first_name like '%" & searchbox.value & "%') or (last_name like '%" & searchbox.value & "%')"
Set oRs = oCon.Execute(strSQL)
strHTML = "<table>"
do while not oRs.EOF
strHTML = strHTML & "<tr><td>" & oRs.fields("first_name") & "</td><td>" & oRs.fields("last_name") & "</td><td>" & oRs.fields("email") & "</td></tr>"
oRs.movenext
loop
oCon.close
strHTML = strHTML & "</table>"
divEmployeeList.innerHTML = strHTML
end Sub
</script>
</head>
<body>
<div id="search"><input type="text" id="searchbox" style="font-size:16pt; margin:10px;"/> <input type="button" value="search" name="submitsearch" style="font-size:16pt;" onclick="getEmployeeList" language="vbscript"></div>
<div id="divEmployeeList" style="width:90%; height:300px; overflow-y:scroll; border:solid 1px #666; margin:10px; background:#fff">-</div>
</body>

can't set width for auxheader in zk

I have a grid in which I want to set the width for auxheader in .zul but it's not working. I am using zk framework.
<grid id="chartGrid" model="#bind(vm.chartGridModel)" mold="paging"
style="overflow:auto" width="100%" >
<auxhead hflex="2" >
<auxheader hflex="2" align="center" width="200px" label="Date" rowspan="3"/>
</auxhead>
<auxhead hflex="1" children="#bind(vm.legendsFB)" visible="#bind(vm.vFb)" >
<auxheader align="center" width="200px" colspan="1"></auxheader>
<template name="children">
<auxheader align="center" label="#bind(each)" colspan="#bind(
vm.viewType eq '0' ? 3 :2)" hflex="2"/>
</template>
</auxhead>
<columns visible="false"><!-- make it invisible -->
<column width="200px"/><!-- specify width here -->
<column width="150px"/>
<column width="50px"/>
<column width="50px"/>
</columns>
<template name="model">
<row>
<cell align="center" ><label value="#load(each.report_date)"></label>
</cell>
<cell align="center"><label value="#load(each.total_action)"></label>
</cell>
<cell align="center"><label value="#load(each.from_user_male)"></label>
</cell>
<cell align="center"><label value="#load(each.from_user_female)"></label>
</cell>
</row>
</template>
</grid>
You set width and colspan.
colspan="x" means you will take the witdh of x columns of your template.
Now you can remove the colspan and it should work, but remember when you set width in px,
Be sure that the total px are the same as the px of all your rows.
You can also do width = "20%", this would mean that you take 20% of your total size of px of the columns.
Its easier to calculate to 100% then your total px.
Greetz chill.

How to design GridView to display with scrolling

How to design GridView in such a way that it display 3 images per row and can be scrolled up for the other Images behind? it seems this gridView displays images in a row.
Below I have 8 Pic in Gridview:
1) How to setup GridView to displays images with(3 images per row) or without specifying number of images per row and the rest will be viewed by scrolling up?
Thanks
< GridView HorizontalAlignment="Left" Margin="30,200,0,0" Grid.Row="1" VerticalAlignment="Top" Width="800" Height="400" >
//-- pic 1
< GridViewItem>
< Grid HorizontalAlignment="Left" Width="200" Height="200">
< Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
< Image Source="Images/M123.jpg" Tag="name" Tapped="Image_Tapped_1" Stretch="UniformToFill"/>
< /Border>
< StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
< TextBlock FontSize="30" Text="name" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"
Style="{StaticResource TitleTextStyle}" Height="40" Margin="15,10,15,0"/>
</StackPanel>
</Grid>
</GridViewItem>
//- pic 2 using GridViewItem
//-- pic 3 using GridViewItem
//--- Pic 3 to Pic 8 GridViewItem
< / GridView>
Put the grid view in a scrollviewer and let the height of the gridview be auto ie it will take the height of the entire content and width of the grid view to a specific one so that t cqn take only 3 items
next step is to just enable the vertical scroll property of the scroll viewer and disable the horizontal scroll property.
i hope this solves the purpose .
try to use jquery plugin
http://gridviewscroll.aspcity.idv.tw/
function gridviewScroll() {
$('#<%=gvMain.ClientID%>').gridviewScroll({
width: 700,
height: 330,
freezesize: 2,
arrowsize: 30,
varrowtopimg: "Images/arrowvt.png",
varrowbottomimg: "Images/arrowvb.png",
harrowleftimg: "Images/arrowhl.png",
harrowrightimg: "Images/arrowhr.png",
headerrowcount: 2
});
}