Skip to content
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

Merged
merged 4 commits into from Oct 8, 2017
Merged

Conversation

mueller-ma
Copy link
Member

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

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>
@hreichert
Copy link

hreichert commented Oct 1, 2017

@mueller-ma That's pretty cool!

Chart themes

👍 Works good.

One note: As the default BasicUI uses the bright theme, I suggest to use the bright theme also for the HABDroid.Basic_ui theme.

Chart DPI

👍 Works good.

Screenshot:
chart_app

Chart legend

I'm not sure about the new setting for "Show chart legend".
The user can already set the legend=true/false attribute in his sitemap definition for the Chart element. But this gets ignored now. Maybe it's better to extend the OpenHABWidget.java and OpenHAB2Widget.java classes for this new sitemap attribute and take this setting to construct the chart URL. (refer to the 'period' attribute)

Here is a screenshot of the widgetJson from a sitemap with Chart with legend=false:
widgetjson
Note: It's a Boolean

Thanks for your work!

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
@mueller-ma
Copy link
Member Author

@hreichert I didn't know, that the legend attribute can be set in the sitemap.
Please test again. Also check what happens if no legend setting is set. The default should be true?

@mueller-ma
Copy link
Member Author

One note: As the default BasicUI uses the bright theme, I suggest to use the bright theme also for the HABDroid.Basic_ui theme.

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.

@hreichert
Copy link

hreichert commented Oct 1, 2017

@mueller-ma

Please see inline comments.

If the legend parameter is not set for a Chart item in the sitemap, the following is the default:

Legend is automatically hidden, if there is only one chart series (-> one item) - otherwise the legend is shown

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 white chart theme is not yet integrated.

@@ -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"));

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;

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)

Copy link
Member Author

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; }

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();

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>
@hreichert
Copy link

@mueller-ma Perfect, everything works as expected! Thanks again for your efforts.
FYI: Here is the PR for the white theme and some other optical improvements: eclipse-archived/smarthome#4368

@mueller-ma
Copy link
Member Author

@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?

@hreichert
Copy link

@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.
But for now I do not want to amend the pending PR, as Kai Kreuzer already approved the changes.

@digitaldan
Copy link
Contributor

lgtm

@digitaldan digitaldan merged commit b1a1991 into openhab:master Oct 8, 2017
@mueller-ma mueller-ma deleted the 383-charts branch October 9, 2017 16:24
@mueller-ma mueller-ma mentioned this pull request Oct 9, 2017
@mueller-ma mueller-ma added the enhancement Indicates new feature requests label Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants