Using vue-ellipse-progress component, is there any way where I can have two different colors for same circle indicating high and low value? - vue.js

I want to indicate the high/low in the circle where I can display the different color if the progress value exceeds 60. Eg, if my value is 80 then till 60 it should show green color and remaining 20 should be in red color. Is it possible to achieve this using vue-ellipse-progress?
<vue-ellipse-progress
:progress="myvariable"
:angle="-90"
color="#1565C0"
emptyColor="#BBDEFB"
:size="180"
:thickness="10"
emptyThickness="15%"
fontColor="black"
dot="10 white"
>
<span>{{myvariable}} </span>
</vue-ellipse-progress>

Got one solution to this. By adding gradient to the color attribute helps to show the colors accordingly.
:color = "gradient"
gradient: {
radial: false,
colors: [
{
color: '#1565C0',
offset: 80,
opacity: '1',
},
{
color: 'red',
offset: 40,
opacity: '1',
},
]
}

Related

Error: "Invalid property type" while checking TextInput

I'm trying to check if user's TextInput is empty but getting error "Invalid property type". I'm programming in kivy.
My kv code:
<Label>
font_size: self.height * .15
background_color: (59/255,191/255,174/255,1)
canvas.before:
Color:
rgba: self.background_color
Rectangle:
size: self.size
pos: self.pos
color: (0/255,0/255,0/255,1)
<TextInput>
multiline: False
input_filter: "int"
font_size: self.height * .15
background_normal: ""
background_color: (192/255,251/255,243/255,1)
color: (0/255,0/255,0/255,1)
<Button>
font_size: self.height * .25
color: (0/255,0/255,0/255,1)
pos_hint: {'center_x': .5}
size_hint: (1, .3)
background_normal: ""
background_color: (8/255, 122/255, 111/255, 1)
<MyLayout>
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
padding: 1
spacing: 1
TextInput:
id: calc_output
text: "waiting for data..."
halign: 'center'
valign: 'center'
font_size: self.height * .20
color: (0/255,0/255,0/255,1)
background_normal: ""
background_color: (1,1,1,1)
size_hint: (1, .3)
GridLayout:
cols: 1
size: root.width, root.height
GridLayout:
cols: 2
padding: 1
spacing: 1
Label:
text: "Broj rođenih"
TextInput:
id: N
Label:
text: "Broj umrlih"
TextInput:
id: M
Label:
text: "Broj stanovnika prve godine"
TextInput:
id: bspg
Label:
text: "Broj stanovnika druge godine"
TextInput:
id: bsdg
Button:
text: "Definiraj tip općeg kretanja stanovništva"
on_press: root.tipopceg()
I tried to check it with:
if - else
while not
try - except
if len()...
Everything I tried I would put in this part of code:
<TextInput>
multiline: False
input_filter: "int"
while not id:
print("You forgot...")
break
or inside every TextInput
Label:
text: "Broj rođenih"
TextInput:
id: N
while not N:
print("You forgot...")
break
but every time I get same error. Since I'm new in this world of programming, I guess I made some minor mistake why program doesn't recognize "id" of every user's TextInput and return error.
Any thoughts?
I don't know if I'm missing something here as well, but ain't kivy a library ? I think the whole purpose of kivy is to make a interface in a more practical way and separated from your logic statements, so the kivy language is made only for interface creation. In that case, I think you are supposed to write your logic part using python, and then call your widgets if you want to make any operation with their properties.
I suggest you take the user input through python, and then use it to define a property of the widget:
self.userinput = TextInput(multiline=False)
Now you can take the property TextInput.text as the actual text inputed by the user. You can check if it's blank with:
if len(self.userinput.text) == 0:
#do something

Creating shape or marks in custom indicator, (tradingview charting library (pinejs))

is there any way to create shape or create marks on chart in custom indicator using tradingview charting library. I am using this way to create custom indicators. Thanks in advance.
Yes you can. Here is the guide.
For the callouts/Markers on chart you can follow this guide in the JS API.
https://github.com/tradingview/charting_library/wiki/JS-Api#gettimescalemarkssymbolinfo-from-to-ondatacallback-resolution
For getmarks you can do this
getMarks: (symbolInfo, startDate, endDate, onDataCallback, resolution) => {
var Arr = [
{
id: 1,
time: 1551448800000 / 1000,
color: 'blue',
text: 'Hello world',
label: 'B',
labelFontColor: 'yellow',
minSize: 20
},
]
onDataCallback(Arr);
console.log("=====getMarks running");
},
It will plot the marks above the bars as shown in the below image.
For Timescalemarks.
getTimescaleMarks: (symbolInfo,startDate,endDate,onDataCallback,resolution) => {
onDataCallback([
{
id: 1,
time: / 1000,
color: 'Turquoise',
label: 'The test you want to show on marker',
minSize: 20,
tooltip:[
"Information you want to print",
]
},
]);
})
The Time scale marks will look like this. And they will be plotted below the bars.
And for the shapes like circles and arrows you can follow this documentation. And use the createMultipointShape(points, options) methos to plot your shapes.
https://github.com/tradingview/charting_library/wiki/Chart-Methods#createmultipointshapepoints-options

show legends on top as like bottom appearance in c3js

I am using c3.js for implementing dashboard. It works pretty fine. But I just want legend on top as appeared at bottom. I want to draw chart as this sequence.
Legends
Chart
Ticks
This is sample figure what is want.
By searching in web, if I set legend configuration like this
legend: {
show: true,
position: 'inset',
inset: {
anchor: 'top-right',
x: 50,
y: 0,
step: 1
}
}
Then legend overlaps main graph as image below:
This is very typical requirement but not available in c3js. How can I do that?.
Use the padding option to set a top gap:
http://c3js.org/reference.html#padding-top
And then set a negative y offset on the inset:
legend: {
position: 'inset',
inset: {
anchor: 'top-right',
x: 50,
y: -30,
step: 1
}
},
padding: {
top: 30
}

dygraphs smooth lines with drawPoints

I used this exmaple http://dygraphs.com/tests/smooth-plots.html to draw smooth lines. When I anable the smoothing by plotter: smoothPlotter small dots at data points disappear. I have set drawPoints: true. Dot is displayed when mouse is on the curve.
How can I enable small dots at data points ( http://dygraphs.com/options.html#drawPoints ) and still use smoothing?
I have not found a way to enable pointdrawing. But you can make a second series with the same data and draw only the points, not the lines. Like so:
new Dygraph(document.getElementById('graph'),
functionData,
{
series: {
Straight: {
color: 'red',
strokeWidth: 0,
drawPoints: true,
pointSize: 7
},
Smoothed: {
plotter: smoothPlotter,
color: 'red',
strokeWidth: 2
}
},
});
http://jsfiddle.net/wLxs4ju1/

Dojo charting: Can i change the color of the line based on the value?

I have a working chart with Dojo 1.8.
chart1 = new dojox.charting.Chart2D("chart1");
chart1.addPlot("default", {type: "Lines", ...
chart1.addSeries("Series A", [{ x: 1, y: 2.3, tooltip: "Value 1"}, ...
My data from the series gets displayed correctly as line and the whole line (series) gets the color 'Green'.
I know how to change the color for the whole series, but would it be possible that the line changes its color based on the data values? Lets assume the x-axis is a time axis and I need the line (series) to be green for until today, and then red for the future values.
Would this be possible and how ?
(I am using markers for the values. If these could change based on the value it would be enough)
I found something something like this in the documentation:
chart.addSeries("Series A", [
{y: 4, color: "red"},
{y: 2, color: "green"},
{y: 1, color: "blue"},
{y: 1, text: "Other", **color: "white", fontColor: "red"**}
]);
But it only works for PIE-charts and not for LINES-charts.
Thank you in advance.
You could try this http://jsfiddle.net/jUS54/
Use styleFunc in the addPlot method for change the markers colors:
var chart1 = new Chart("simplechart");
chart1.addPlot("default", {type: Lines, markers:true, styleFunc: function(item {
if(item <= 2){
return { fill : "red" };
}else if(item > 3){
return { fill: "green" };
}
return {};
}});
You can change the color by adding 'fill' to your chart data. Basically, loop through your input data deciding what to set your fill too while constructing the JSON for chartData.
var chartData = [{y: 10000,fill: "red"},{y:9200,fill: "yellow"},{y:11811,fill: "green"},{y:12000,fill: "blue"},{y:7662,fill: "blue"},{y:13887,fill: "black"},{y:14200,fill: "gray"},{y:12222,fill: "purple"},{y:12000,fill: "green"},{y:10009,fill: "purple"},{y:11288,fill: "green"},{y:12099,fill: "blue"}];
http://jsfiddle.net/goinoff/QnNk2/1/