def test_id_not_valid(self): my_box = { 'type': 'box', 'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1' } message = ( "Your box_id must be a number in your dashboard. To view a " "representation of your dashboard run get_preview()." ) dash = dashboard.Dashboard() dash.insert(my_box, 'above', 1) # insert box self.assertRaisesRegexp(PlotlyError, message, dash.insert, my_box, 'above', 0) # get box by id self.assertRaisesRegexp(PlotlyError, message, dash.get_box, 0) # remove box self.assertRaisesRegexp(PlotlyError, message, dash.remove, 0)
def test_invalid_path(self): my_box = { 'type': 'box', 'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1' } dash = dashboard.Dashboard() message = ( "Invalid path. Your 'path' list must only contain " "the strings 'first' and 'second'." ) self.assertRaisesRegexp(PlotlyError, message, dash._insert, my_box, 'third')
def test_invalid_side(self): my_box = { 'type': 'box', 'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1' } message = ( "If there is at least one box in your dashboard, you " "must specify a valid side value. You must choose from " "'above', 'below', 'left', and 'right'." ) dash = dashboard.Dashboard() dash.insert(my_box, 'above', 0) self.assertRaisesRegexp(PlotlyError, message, dash.insert, my_box, 'somewhere', 1)
def test_box_id_none(self): my_box = { 'type': 'box', 'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1' } dash = dashboard.Dashboard() dash.insert(my_box, 'above', None) message = ( "Make sure the box_id is specfied if there is at least " "one box in your dashboard." ) self.assertRaisesRegexp(PlotlyError, message, dash.insert, my_box, 'above', None)
def test_dashboard_dict(self): my_box = { 'type': 'box', 'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1' } dash = dashboard.Dashboard() dash.insert(my_box) dash.insert(my_box, 'above', 1) expected_dashboard = { 'layout': {'direction': 'vertical', 'first': {'direction': 'vertical', 'first': {'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1', 'type': 'box'}, 'second': {'boxType': 'plot', 'fileId': 'AdamKulidjian:327', 'shareKey': None, 'title': 'box 1', 'type': 'box'}, 'size': 50, 'sizeUnit': '%', 'type': 'split'}, 'second': {'boxType': 'empty', 'type': 'box'}, 'size': 1500, 'sizeUnit': 'px', 'type': 'split'}, 'settings': {}, 'version': 2 } self.assertEqual(dash['layout'], expected_dashboard['layout'])
def upload_dashboard(): recent_dashboards = py.dashboard_ops.get_dashboard_names() if dashboard_name not in recent_dashboards: dboard = dashboard.Dashboard() # Insert boxes # dboard.insert(box_c) dboard.insert(box_a) dboard.insert(box_c, 'right', 1) # Insert title dboard['settings']['title'] = dashboard_name # dboard['layout']['size'] = 3000 dboard['settings']['foregroundColor'] = '#000000' dboard['settings']['backgroundColor'] = '#adcaea' dboard['settings']['headerForegroundColor'] = '#ffffff' dboard['settings']['headerBackgroundColor'] = '#008fb3' dboard['settings']['boxBackgroundColor'] = '#ffffff' dboard['settings']['boxBorderColor'] = '#000000' dboard['settings']['boxHeaderBackgroundColor'] = '#ffffff' # Upload dashboard dashboard_url = py.dashboard_ops.upload(dboard, dashboard_name) return dashboard_url else: return py.dashboard_ops.get_dashboard(dashboard_name)
average_mark += [row[1]] avarage_marks = go.Scatter(x=cource, y=average_mark, mode='lines+markers') data = [avarage_marks] avg_marks = py.plot(data, filename='avg_marks', auto_open=False) #---------------------creating dashboard---------------------------- def fileId_from_url(url): """Return fileId from a url.""" raw_fileId = re.findall("~[A-z0-9.]+/[0-9]+", url)[0][1:] return raw_fileId.replace('/', ':') dashboard_hw = dashboard.Dashboard() box_1 = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(students_cources), 'title': 'count of students at cources' } box_2 = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(teachers_students), 'title': 'teachers and their students' }
box_map = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_map, 'title': 'Neemboriyan', } ###TimeSeries box_plot = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_plot, 'title': 'Neem Branches', } ##Creating Dashboard NeemDash = dashboard.Dashboard() #NeemDash=['layout']['size'] = 3000 ### Insert box in dashboard NeemDash.insert(box_plot) NeemDash.insert(box_map, 'left', 1, fill_percent=40) ###Styling Dashboard NeemDash['settings']['title'] = 'National Energy End-use Monitoring Dashboard' NeemDash['settings'][ 'logoUrl'] = 'http://edsglobal.com/images/homepagetext/basetext/EDS.png' NeemDash['settings']['links'] = [] NeemDash['settings']['links'].append({ 'title': 'Environmental Design Solutions', 'url': 'http://www.edsglobal.com/' })
for row in cursor: print("Classroom number: ", row[0], " and number of objects : ", row[1]) classroom_number_2 += ["№ " + str(row[0])] chair_desk_blackboard_count += [row[1]] Classroom_objects = go.Scatter(x=classroom_number_2, y=chair_desk_blackboard_count, mode='lines+markers') data = [Classroom_objects] Classroom_objects_url = py.plot(data, filename='scatter') # In[8]: """--------CREATE DASHBOARD------------------ """ my_dboard = dashboard.Dashboard() classrooms_chair_count_id = fileId_from_url(classrooms_chair_count) color_desk_count_id = fileId_from_url(color_desk_count) Classroom_objects_url_id = fileId_from_url(Classroom_objects_url) print(classrooms_chair_count_id) box_1 = { 'type': 'box', 'boxType': 'plot', 'fileId': classrooms_chair_count_id, 'title': 'Classrooms and count of chairs' } box_2 = {
def MakeBoard(pie_url, line_url, table_url): # pie_url (list), line_url (not a list), table_url (list) print('Dashboard: assembling plots') dboard = dashboard.Dashboard() table_tracklist = tracklist[::-1] table_box0 = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(table_url[table_tracklist[0]]), 'shareKey': None, 'title': 'Tweets Containing Keyword: {}'.format(table_tracklist[0]) } dboard.insert(table_box0) # insert table if len(table_url) >= 2: for i in table_tracklist[1:]: table_box = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(table_url[i]), 'shareKey': None, 'title': 'Tweets Containing Keyword: {}'.format(i) } dboard.insert(table_box, 'above', 1, fill_percent=70) line_box = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(line_url), 'shareKey': None, 'title': 'Average Sentiment (per {})'.format(groupby_freq) } dboard.insert(line_box, 'above', 1, fill_percent=57) # insert time series fmt = '%Y-%m-%d %H:%M:%S %Z%z' time = datetime.datetime.utcnow().replace(tzinfo=pytz.utc).astimezone( pytz.timezone(tmzone)) time_str = time.strftime(fmt) m = 'Last updated at : {} ({}). \nRefreshing every {} minutes.'.format( time_str, tmzone, update_freq) text_box = {'type': 'box', 'boxType': 'text', 'text': '', 'title': m} dboard.insert(text_box, 'above', 1, fill_percent=4) # insert message box pie_box0 = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(pie_url[tracklist[0]]), 'shareKey': None, 'title': 'Overall Sentiment ({})'.format(tracklist[0]) } dboard.insert(pie_box0, 'left', 2, fill_percent=25) # insert pie if len(pie_url) >= 2: for i in tracklist[1:]: pie_box = { 'type': 'box', 'boxType': 'plot', 'fileId': fileId_from_url(pie_url[i]), 'shareKey': None, 'title': 'Overall Sentiment ({})'.format(i) } dboard.insert(pie_box, 'below', 2) # dashboard setting dboard['settings'][ 'title'] = 'Real-time Twitter Sentiment Analysis ({} vs. {})'.format( tracklist[0], tracklist[-1]) dboard['settings']['fontFamily'] = 'Overpass' dboard['settings'][ 'logoUrl'] = 'https://www.xtendlabs.com/static/images/xtendlabs.png' dboard['settings']['links'] = [{ 'title': '***Click here to check our website***', 'url': 'https://www.xtendlabs.com/' }] dboard['layout']['size'] = 2000 # change length # dboard['settings']['foregroundColor'] = '#000000' # dboard['settings']['backgroundColor'] = '#adcaea' # dboard['settings']['headerForegroundColor'] = '#ffffff' # dboard['settings']['headerBackgroundColor'] = '#D232C8' # dboard['settings']['boxBackgroundColor'] = '#ffffff' # dboard['settings']['boxBorderColor'] = '#000000' # dboard['settings']['boxHeaderBackgroundColor'] = '#ffffff' if platform == "linux" or platform == "linux2": auto_open = False else: auto_open = True dashboard_url = py.dashboard_ops.upload(dboard, 'Dashboard', auto_open=auto_open) print('Done! Check Website: {}\n'.format(dashboard_url)) return dashboard_url
ORDER BY patientcard.appointment """) dates = [] patients = [] for row in cursor: print("Date ", row[0], " count: ", row[1]) dates += [row[0]] patients += [row[1]] date_patients = go.Scatter(x=dates, y=patients, mode='lines+markers') data = [date_patients] date_patient = py.plot(data, filename='Appointments by date') """--------CREATE DASHBOARD------------------ """ my_board = dashboard.Dashboard() doctors_patient_count_id = fileId_from_url(doctors_patient_count) doctor_patient_percent_id = fileId_from_url(doctor_patient_percent) date_patient_id = fileId_from_url(date_patient) box_1 = { 'type': 'box', 'boxType': 'plot', 'fileId': doctors_patient_count_id, 'title': 'Doctors and count of his patients' } box_2 = { 'type': 'box', 'boxType': 'plot',