Charting in OH2

Hi I would like to select between “hour”, “Day” and “week” for my charting like it is in the demo of OH1.7 . I copy code from the demo sitemap however I don’t get the the buttons like it is in this demo.

This is what I get with the same code why will it be? It also show all the charts at the same time. I user the basic UI in OH2. I also get the same results in the classic UI.

Are you sure that you correctly set up the item and the sitemap? The Item for chart period has to be of type Number. In the sitemap, the item needs a mapping:
Switch item=chart_period mappings=[1=Hour,2=Day,3=Week]
and the chart definition in the sitemap needs a part
visibility=[chart_period==[1|2|3]] /1,2 or 3

HI Udo This is the way I have it in my sitemap.

Frame { Switch item=Power_Chart_Period label="Chart Period" mappings=[0=Hour, 1=Day, 2=Week] Chart item=GF_Power period=h refresh=6000 visibility=[Power_Chart_Period==0, Power_Chart_Period=="Uninitialized"] Chart item=GF_Power period=D refresh=30000 visibility=[Power_Chart_Period==1] Chart item=GF_Power period=W refresh=30000 visibility=[Power_Chart_Period==2] }

The Sitemap seems to be ok so far, what’s about the definition of Power_Chart_Period?

Thanks I have this now working but it is not changing to the chart that I click on I have to refresh the page for it to happen why will that be?

Yes, it’s possible that the refresh doesn’t work as expected, I think, there is an Issue at github… I’m not sure if it is fixed already, but afaik it should be at least in OH1.8.3

HI Udo Thanks for you help :slight_smile:

Hi,

please excuse me to link me into the thread, but at the moment I am facing exactly the same problem.
What did you do to make it work?

Thank you!

my solution:

you had to define an item in items map
/************ chart Items ***************************/
Number Chart_Intervall “Chart_Intervall”

than in sitemaps

/************ chart sitemap **********************/
Frame label=“Charts”{
Text label=“Temp. EG” icon="groundfloor"
Switch item=Chart_Intervall label=“Zeitraum” icon=“clock” mappings=[0=“Stunde”, 1=“Tag”, 2=“Woche”]
Chart item=gTempChartEG service=“rrd4j” period=h refresh=300 visibility=[Chart_Intervall==0, Chart_Intervall==“Uninitialized”]
Chart item=gTempChartEG service=“rrd4j” period=D refresh=300 visibility=[Chart_Intervall==1]
Chart item=gTempChartEG service=“rrd4j” period=W refresh=300 visibility=[Chart_Intervall==2]
}