I have a chart setup what I needed to show positive and negative numbers in different colours,
how I have achieved this is to check the value before hand and set the topic to High or Low depending on its value.
But now I have graphs that look like this.
Ideally it would put both lines on top of each other, or not plot the 0 for the the other topic when the value isn't being used.
Below is the code I used to find the negativity
if (pl <= 0){
pl2 = pl
pl1 = 0
} else {
pl2 = 0
pl1 = pl
}
//series 1 #green
msg = {
payload: pl1,
timestamp: ts,
topic: "high"
},
//series 2 #red
msg2 = {
payload: pl2,
timestamp: ts,
topic: "low"
}
if (pl > 0){
return msg
}
else {
return msg2
}
The answer may be somewhere in this thread
I need to have a bar chart with stacked columns. Unfortunately this is not an option you can find in the configuration window (why?, it's a super standard bar chart style ), so I followed HotNipi's Feb. 10th post suggesting to use msg.ui_control :
msg.ui_control = {
options: {
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true
}]
}
}
}
It works, but it has some undesired side-ef…
That does get me part way there, I'm still showing 0 values though which I'd like to hide if possible.
What if you set null
for values you don't need to show?
I'm not sure how I would do this because I only ever send one payload just with a different topic.
Edit: Also I hate how the time has decided to slant itself, looking at the docs now to see fi that can be controlled.
Infact after the chart has moved on a bit I've noticed its working exactly as required, just need to sort the text out and it'll be perfect
@hotNipi Sorry to tag you.
I use a chart pre-formatter to set my axis max and min to fix values so all charts (9) loot the same and can be compared without interpreting the axis.
Is there a way to fix the values using ui control as I am not having much luck.
If they really are always the same why not fix them in the config ?
But yes you can set them with ui_control - see
## UI Widget configuration via msg.ui_control
The following configuration properties of ui widget nodes can be set by using a `msg.ui_control` property on a msg.
Multiple properties of the node can be set at the same time. For example you can use a change
node to set msg.ui_control to JSON `{ "min":10, "max":50 }`
**Note**: It is still recommended that nodes are configured via the editor in order to preset the default values.
|widget |property |type | notes / example
|--- |--- |--- |---
|ui_button |color |string | not needed
| |bgcolor |string | not needed
| |icon |string | on refresh
| |format |string | not needed
| |tooltip |string | on refresh
|ui_chart |look |string |"line","bar","horizontalBar","pie","polar-area","radar"
| |legend |boolean |
| |interpolate |string |"linear","step","bezier"
| |nodata |string |
This file has been truncated. show original
I have set them in the config, but since adding the ui_control lines above it is ignoring them
@hotNipi @dceejay
Its funny both those code work individually but when I put them together whichever one is on top wins.
I'm currently using
ui= {
options: {
"Max": 60,
"Min": -140
},
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true
}]
}
}
but that doesn't stack the bars, if I put the mix/max at the bottom it does fit the axis.
Hopefully I'm just doing something stupid.
I pass ui_control: ui
when I build my message
edit: Sorry, when my code is like above I get fixed axis, when I use
ui= {
options: {
"Max": 60,
"Min": -140,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true
}]
}}
}
I lose the fix axis
@dceejay I notice that your the author of that config-fields.md you link me.
I've been playing with the interactive bit on this website: Stacked Bar Chart | Chart.js
And using
const config = {
type: 'bar',
data: data,
options: {
plugins: {
title: {
display: true,
text: 'Chart.js Bar Chart - Stacked'
},
},
responsive: true,
scales: {
xAxes: {
stacked: true,
},
yAxes: {
stacked: true,
min:-75,
max:50
}
}
}
};
limits the data as you would expect, but when I use the same options layout for the node it doesn't.
I don't know if the ui dashboard isn't using the latest version of Chart.js. I 'm wondering if you could explain why it doesn't work?
After a bit more digging and looking at the angular-chartjs documentation for 2.6.0 I see the options used to be under ticks. So I can do what i need to do by using
ui= {
options: {
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true,
ticks: {
max: 60,
min: -140
}
}]
}
}
}
What a journey, thanks for you time.
1 Like
system
Closed
30 July 2021 14:06
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.