Pine Script version 5 - style=plot.style_line is plotted as interrupted line - pine-script-v5

I made a pine script for trading view indicator. I want it to plot an uninterrupted line, however I see interrupted line (dashed line) being plotted. I don't know how to resolve this.
I follow the pine script Version 5 user manual on tradingview, but couldn't track the problem.
//#version=5
//Coded by: NawidD.
indicator(title=‘test’ fibonacci, overlay=true)
HighPoint = input(1.6, title='Set the high level)
LowPoint = input(1.5, title='Set the low level')
m = input.float(title='Set the gap', defval=0.1)
Fhigh = HighPoint
Flow = LowPoint
//First data
F0 = Flow
F236 = (Fhigh - Flow) * 0.236 + Flow
F382 = (Fhigh - Flow) * 0.382 + Flow
F500 = (Fhigh - Flow) * 0.500 + Flow
F618 = (Fhigh - Flow) * 0.618 + Flow
F786 = (Fhigh - Flow) * 0.786 + Flow
F1000 = (Fhigh - Flow) * 1.000 + Flow
Fcolor = #00bfff
plot(F0, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0', editable=false)
plot(F236, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, show_last=1, title='Base: 0.5 level', editable=true)
plot(F618, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, show_last=1, title='Base: 0.618 level', editable=true)
plot(F786, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='1', editable=false)
//1st increment plot
plot(F0 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0', editable=false)
plot(F236 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='1st increment: 0.5 level', editable=true)
plot(F618 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='1st increment: 0.618 level', editable=true)
plot(F786 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='1', editable=false)
//1st increment plot labels
//plotshape(F0 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%0', offset=5, editable=false)
//plotshape(F236 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%23.6', offset=5, editable=false)
//plotshape(F382 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%38.2', offset=5, editable=false)
//plotshape(F500 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), show_last=1, text='%50', offset=5, editable=false)
//plotshape(F618 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), show_last=1, text='%61.8', offset=5, editable=false)
//plotshape(F786 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%78.6', offset=5, editable=false)
//plotshape(F1000 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%100', offset=5, editable=false)
//2nd increment plot
plot(F0 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0', editable=false)
plot(F236 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='2nd increment: 0.5 level', editable=true)
plot(F618 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='2nd increment 0.618 level', editable=true)
plot(F786 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='1', editable=false)

//#version=5
//Coded by: NawidD.
indicator(title='test fibonacci', overlay=true)
HighPoint = input.float(1.6, title='Set the high level')
LowPoint = input.float(1.5, title='Set the low level')
m = input.float(defval=0.1, title='Set the gap')
Fhigh = HighPoint
Flow = LowPoint
//First data
F0 = Flow
F236 = (Fhigh - Flow) * 0.236 + Flow
F382 = (Fhigh - Flow) * 0.382 + Flow
F500 = (Fhigh - Flow) * 0.500 + Flow
F618 = (Fhigh - Flow) * 0.618 + Flow
F786 = (Fhigh - Flow) * 0.786 + Flow
F1000 = (Fhigh - Flow) * 1.000 + Flow
Fcolor = #00bfff
plot(F0, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0', editable=false)
plot(F236, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.236', editable=false)
plot(F382, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.382', editable=false)
plot(F500, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=false, title='Base: 0.5 level', editable=true)
plot(F618, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=false, title='Base: 0.618 level', editable=true)
plot(F786, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.786', editable=false)
plot(F1000, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='1', editable=false)
//1st increment plot
plot(F0 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0', editable=false)
plot(F236 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.236', editable=false)
plot(F382 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.382', editable=false)
plot(F500 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='1st increment: 0.5 level', editable=true)
plot(F618 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='1st increment: 0.618 level', editable=true)
plot(F786 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.786', editable=false)
plot(F1000 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='1', editable=false)
//1st increment plot labels
//plotshape(F0 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), text='%0', offset=5, editable=false)
//plotshape(F236 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), text='%23.6', offset=5, editable=false)
//plotshape(F382 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), text='%38.2', offset=5, editable=false)
//plotshape(F500 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), text='%50', offset=5, editable=false)
//plotshape(F618 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), text='%61.8', offset=5, editable=false)
//plotshape(F786 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), text='%78.6', offset=5, editable=false)
//plotshape(F1000 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), text='%100', offset=5, editable=false)
//2nd increment plot
plot(F0 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0', editable=false)
plot(F236 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.236', editable=false)
plot(F382 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.382', editable=false)
plot(F500 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='2nd increment: 0.5 level', editable=true)
plot(F618 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='2nd increment 0.618 level', editable=true)
plot(F786 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.786', editable=false)
plot(F1000 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='1', editable=false)

Related

I want to work expanded menu in Flutter of the data shown in the list

I want to make a list that looks like the image from the data shown below. I haven't tried anything because I don't know how to do it.
Illustration of similar work:
Code:
class Meue {
int id;
String desc;
int parent;
Meue(
{
required this.id,
required this.desc,
required this.parent}
);
}
List<Meue> itemsMenue=[
Meue(id: 1,desc:'number 1' ,parent:0 ),
Meue(id: 2,desc:'number 2' ,parent: 0),
Meue(id: 3,desc:'number 3' ,parent: 0),
Meue(id: 4,desc:'number 4' ,parent: 0),
Meue(id: 5,desc:'number 5' ,parent: 0),
Meue(id: 6,desc:'number 6' ,parent: 1),
Meue(id: 7,desc:'number 7' ,parent: 1),
Meue(id: 8,desc:'number 8' ,parent: 1),
Meue(id: 9,desc:'number 9' ,parent: 1),
Meue(id: 10,desc:'number 10' ,parent:1 ),
Meue(id: 11,desc:'number 11' ,parent: 2),
Meue(id: 12,desc:'number 12' ,parent: 2),
Meue(id: 13,desc:'number 13' ,parent: 2),
Meue(id: 14,desc:'number 14' ,parent: 2),
Meue(id: 15,desc:'number 15' ,parent: 2),
Meue(id: 16,desc:'number 16' ,parent: 2),
Meue(id: 17,desc:'number 17' ,parent: 3),
Meue(id: 18,desc:'number 18' ,parent: 3),
Meue(id: 19,desc:'number 19' ,parent: 3),
Meue(id: 20,desc:'number 20' ,parent: 3),
Meue(id: 21,desc:'number 21' ,parent: 3),
Meue(id: 22,desc:'number 22' ,parent: 3),
Meue(id: 23,desc:'number 23' ,parent: 4),
Meue(id: 24,desc:'number 24' ,parent: 4),
Meue(id: 25,desc:'number 25' ,parent: 4),
Meue(id: 26,desc:'number 26' ,parent: 4),
Meue(id: 27,desc:'number 27' ,parent: 4),
Meue(id: 28,desc:'number 28' ,parent: 30),
Meue(id: 29,desc:'number 29' ,parent: 31),
Meue(id: 30,desc:'number 30' ,parent: 29),
Meue(id: 31,desc:'number 31' ,parent: 28),
];

How can i create custom shape widget in flutter? which is dynamically render in all mobile devices

I want to add a custom profile avatar to one of my projects. I tried with the custom painter & clipper. But, when I test in different devices the shape & size are not as my designer gave to me.
This is my painter class.
import 'package:flutter/material.dart';
class ProfileBox extends CustomPainter {
#override
void paint(Canvas canvas, Size size) {
final paint = Paint();
paint.color = Colors.grey;
paint.style = PaintingStyle.fill;
final path = Path();
path.moveTo(25, 4);
path.quadraticBezierTo(size.width / 2, -4, size.width - 25, 4);
path.quadraticBezierTo(size.width - 10, 10, size.width - 4, 25);
path.quadraticBezierTo(
size.width + 4, size.height / 2, size.width - 4, size.height - 25);
path.quadraticBezierTo(
size.width - 10, size.width - 10, size.width - 25, size.height - 4);
path.quadraticBezierTo(
size.width / 2, size.height + 4, 25, size.height - 4);
path.quadraticBezierTo(10, size.height - 10, 4, size.height - 25);
path.quadraticBezierTo(-4, size.height / 2, 4, 25);
path.quadraticBezierTo(10, 10, 25, 4);
canvas.drawPath(path, paint);
}
#override
bool shouldRepaint(CustomPainter oldDelegate) {
return this != oldDelegate;
}
}
This is my clipper class.
import 'package:invoice_app/constants/globals.dart';
class ProfileClipper extends CustomClipper<Path> {
ProfileClipper({#required this.profileSize});
final ProfileSize profileSize;
#override
Path getClip(Size size) {
final path = Path();
path.moveTo(23, 2);
path.quadraticBezierTo(size.width / 2, -4, size.width - 23, 2);
path.quadraticBezierTo(size.width - 8, 8, size.width - 2, 23);
path.quadraticBezierTo(
size.width + 4, size.height / 2, size.width - 2, size.height - 23);
path.quadraticBezierTo(
size.width - 8, size.width - 8, size.width - 23, size.height - 2);
path.quadraticBezierTo(
size.width / 2, size.height + 4, 23, size.height - 2);
path.quadraticBezierTo(8, size.height - 8, 2, size.height - 23);
path.quadraticBezierTo(-4, size.height / 2, 2, 23);
path.quadraticBezierTo(8, 8, 23, 2);
return path;
}
#override
bool shouldReclip(covariant CustomClipper<Path> oldClipper) => false;
}
And, I'm using it in UI with the below widget.
painter: ProfileBox(),
child: Container(
padding: const EdgeInsets.all(5),
height: 100,
width: 100,
child: ClipPath(
clipper: ProfileClipper(profileSize: ProfileSize.smallProfile),
child: Container(
// if image url is null and want to display icon or svg then add padding
padding: _imageFile != null
? const EdgeInsets.all(0)
: const EdgeInsets.all(13),
// color: Colors.blue,
child: Image(
// if image url is null then display icon or svg
image: _imageFile != null
? FileImage(_imageFile)
: AssetImage(
'assets/defaultbusiness.png',
),
fit: BoxFit.fill,
),
),
),
),
),

Optimal number of clusters - Error in FUNcluster(x, i, ...) : more cluster centers than distinct data points

I have these data and I need to find the optimal number of clusters of this table.
The values can be either 0, 0.5 or 1
library(NbClust)
library(factoextra)
library(pheatmap)
tab=structure(list(`57-B1` = c(1, 0.5, 0.5, 1, 1, 0.5), `57-B3` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `57-C1` = c(1, 0.5, 0.5, 0.5, 1, 0.5),
`57-C5` = c(1, 0.5, 0.5, 1, 1, 1), `57-H2` = c(1, 0.5, 0.5,
0, 1, 1), `57-H4` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5), `61-1-B1` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `61-1-C2` = c(0.5, 0.5, 0.5, 0, 0.5,
0.5), `61-1-C5` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5), `61-1-H1` = c(0.5,
0.5, 0, 0, 0.5, 0.5), `61-1-H3` = c(0.5, 0.5, 0.5, 0, 0.5,
0.5), `61-1-H5` = c(0.5, 0.5, 0, 0.5, 0.5, 0.5), `62-2_H2` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `62_1_C2` = c(0.5, 0.5, 0, 0.5, 0.5,
0.5), `62_1_C5` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5), `FL-39-C3` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `FL-41-1-C3` = c(0.5, 0.5, 0.5, 0,
0.5, 0.5), `FL-57-B1` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5), `FL-57-B2` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `FL-57-C2` = c(0.5, 0.5, 0, 0.5,
0.5, 0.5), `FL-57-C3` = c(1, 1, 1, 0, 1, 1), `FL-57-C5` = c(1,
0.5, 0.5, 1, 1, 1), `FL-57-H1` = c(1, 0.5, 0.5, 1, 1, 1),
`FL-57-H4` = c(0.5, 0.5, 0, 0, 0.5, 0.5), `FL-57-H5` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `FL-61-1-B1` = c(0.5, 0.5, 0.5, 0,
0.5, 0.5), `FL-61-1-B4` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5),
`FL-61-1-C2` = c(0.5, 0.5, 0, 0, 0.5, 0.5), `FL-61-1-C4` = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), `FL-61-1-H3` = c(0.5, 0.5, 0.5, 0,
0.5, 0.5), `FL-61-1-H4` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5),
`FL-61-1-H5` = c(0.5, 0.5, 0, 0.5, 0.5, 0.5), `FL-62-1-C3` = c(0.5,
0.5, 0, 0.5, 0.5, 0.5), `FL-62-2-H2` = c(0.5, 0.5, 0.5, 0,
0.5, 0.5), `FL-73-H1` = c(0.5, 0.5, 0.5, 0, 0.5, 0.5), P_57_F = c(0.5,
0.5, 0.5, 0, 0.5, 0.5), P_57_M = c(0.5, 0.5, 0.5, 0, 0.5,
0.5)), row.names = c("g1", "g2", "g3", "g4", "g5", "g6"), class = "data.frame")
I tried both on scaled and non-scale values:
fviz_nbclust(scale(tab), kmeans, method = "wss")
fviz_nbclust(tab, kmeans, method = "wss")
and I get this error:
Error in FUNcluster(x, i, ...) :
more cluster centers than distinct data points.
how can I fix it?
Many thanks for your help !
I maybe found the solutions: it was sufficient to specify k.max = any number lower than nrow(tab)

How to draw a hexagon shape in flutter?

I wanted to draw a hexagon shape but I couldn't do what I wanted.
this is my result:
Path createHexagonPath() {
const int SIDES_OF_HEXAGON = 6;
const double radius = 50;
const Offset center = Offset(50, 50);
final path = Path();
var angle = (pi * 2) / SIDES_OF_HEXAGON;
Offset firstPoint = Offset(radius * cos(0.0), radius * sin(0.0));
path.moveTo(firstPoint.dx + center.dx, firstPoint.dy + center.dy);
for (int i = 1; i <= SIDES_OF_HEXAGON; i++) {
double x = radius * cos(angle * i) + center.dx;
double y = radius * sin(angle * i) + center.dy;
path.lineTo(x, y);
}
path.close();
return path;
}
I want that to be the case:
go over to this website https://fluttershapemaker.com it is simple and easy
you can try this, polygon_clipper with flutter_neumorphic
Neumorphic(
style: NeumorphicStyle(
depth: -5,
lightSource: LightSource.topLeft,
color: Colors.grey
),
child:
ClipPolygon(
sides: 6,
borderRadius: 5.0, // Default 0.0 degrees
rotate: 90.0, // Default 0.0 degrees
boxShadows: [
PolygonBoxShadow(color: Colors.black, elevation: 1.0),
PolygonBoxShadow(color: Colors.grey, elevation: 5.0)
],
child: Container(color: Colors.black),
),
)

How to fill color inside a shape created using CustomPainter drawPath?

So, I've created a shape using drawPath and drawArc from CustomPainter, the PaintingStyle is stroke, but when I change it to fill, it only fills the arcs and not the whole shape.
I want to fill the shape I created with a color, so how can I fill the shape with a particular color?
class CustomShapeCard extends CustomPainter {
CustomShapeCard({#required this.strokeWidth, #required this.color});
final double strokeWidth;
final Color color;
#override
void paint(Canvas canvas, Size size) {
var paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = strokeWidth
..color = color;
var path = Path();
path.moveTo(size.width * 0.1, size.height * 0.2);
path.lineTo(size.width * 0.1, size.height * 0.9);
canvas.drawPath(path, paint);
canvas.drawArc(
Rect.fromCenter(
center: Offset((size.width * 0.2) - 14, size.height * 0.9),
height: 50,
width: 50,
),
math.pi / 2,
math.pi / 2,
false,
paint,
);
path.moveTo((size.width * 0.2) - 14, (size.height * 0.9) + 25);
path.lineTo((size.width * 0.9) - 25, size.height * 0.9 + 25);
canvas.drawPath(path, paint);
canvas.drawArc(
Rect.fromCenter(
center: Offset((size.width * 0.9) - 25, size.height * 0.9),
height: 50,
width: 50,
),
math.pi / 2,
-math.pi / 2,
false,
paint,
);
path.moveTo((size.width * 0.9), (size.height * 0.9));
path.lineTo(size.width * 0.9, size.height * 0.35);
canvas.drawPath(path, paint);
canvas.drawArc(
Rect.fromCenter(
center: Offset((size.width * 0.9) - 25, size.height * 0.35),
height: 50,
width: 50,
),
-math.pi / 2,
math.pi / 2,
false,
paint,
);
path.moveTo((size.width * 0.9) - 25, (size.height * 0.35) - 25);
path.lineTo(size.width * 0.25, (size.height * 0.35) - 25);
canvas.drawPath(path, paint);
canvas.drawArc(
Rect.fromCenter(
center: Offset((size.width * 0.25), (size.height * 0.35) - 50),
height: 50,
width: 50,
),
math.pi / 2,
math.pi / 3,
false,
paint,
);
path.moveTo((size.width * 0.25) - 20, (size.height * 0.35) - 35);
path.lineTo(size.width * 0.1, size.height * 0.2);
canvas.drawPath(path, paint);
}
#override
bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
}
When the PaintingStyle is stroke, I get this,
When I change PaintingStyle to fill, I get,
To fill a shape like this with a color,
the arcToPoint() should be used instead of drawArc().