New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make use of eclipse/smarthome#4291 #386
Conversation
This commit enhances charts to support themes, scale legend according to dpi and create option to hide legend Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
@mueller-ma That's pretty cool! Chart themes👍 Works good. One note: As the default BasicUI uses the Chart DPI👍 Works good. Chart legendI'm not sure about the new setting for "Show chart legend". Here is a screenshot of the widgetJson from a sitemap with Thanks for your work! |
Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
@hreichert I didn't know, that the legend attribute can be set in the sitemap. |
Since this is my personal opinion that white looks better than bright, please take two screenshots and post it here and maybe in the forum and make a poll. |
Please see inline comments. If the
BasicUI theme: In my opinion, white looks also better and more modern. Right now I can not take screenshots, because my OH runs currently on the official snapshot distro, and the |
@@ -64,6 +64,8 @@ private OpenHAB2Widget(OpenHABWidget parent, JSONObject widgetJson, String iconF | |||
this.setPeriod(widgetJson.getString("period")); | |||
if (widgetJson.has("service")) | |||
this.setService(widgetJson.getString("service")); | |||
if (widgetJson.has("legend")) | |||
this.setService(widgetJson.getString("legend")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong setter called
@@ -25,7 +25,8 @@ | |||
private String type; | |||
private String url; | |||
private String period = ""; | |||
private String service = ""; | |||
private String service = ""; | |||
private boolean legend = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest a Boolean
with default null
here, so that the behaviour is similiar to the other UI providers:
If the user does not set a legend
attribute, it is not delivered in the REST API, and this should stay null.
In the OpenHABWidgetAdapter
, check if this is not-null, and only append the `legend´ parameter to the chart URL if this is non-null.
(See comment in PR regarding default handling)
This gives the following behaviour:
- User defines
legend
with true/false: legend parameter is appended to URL, respect users wish - User does NOT define
legend
: do not append legend parameter -> the OH ChartProvider takes the default (show legend if more than one item)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was aware of this problem, but couldn't find a good solution. Thanks!
@@ -192,6 +193,10 @@ public void setPeriod(String period) { | |||
|
|||
public void setService(String service) { this.service = service; } | |||
|
|||
public boolean getLegend() { return legend; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above: Boolean
chartUrl += "&dpi=" + dpi; | ||
|
||
// add legend | ||
chartUrl += "&legend=" + openHABWidget.getLegend(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only add legend
parameter to URL if openHABWidget.getLegend() != null
; see above
Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
@mueller-ma Perfect, everything works as expected! Thanks again for your efforts. |
@hreichert Does the background of the charts always match the background of the app? Do you think a theme with a transparent background and bright font would be a good addition? |
@mueller-ma The current themes do match the colors from the "Hell", "Dunkel" and "Schwarz/AMOLED" app themes (I have currently only the german theme names available). A transparent theme is, among other things, on my todo list for future chart improvements. |
lgtm |
This commit enhances charts to support themes, scale legend according to
dpi and create option to hide legend
Signed-off-by: mueller-ma mueller-ma@users.noreply.github.com
See #373