def test_lineplusbarwithfocuschart(self): "Test LinePlusBar With FocusChart" type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, color_category='category20b', x_is_date=True, x_axis_format="%d %b %Y") chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 100 xdata = list(range(nb_element)) start_time = int( time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) #prepare series xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(-10, 10) for i in range(nb_element)] ydata2 = [200 - i + random.randint(-10, 10) for i in range(nb_element)] extra_serie_1 = { "tooltip": { "y_start": "$ ", "y_end": "" }, "date_format": "%d %b %Y", } kwargs = {"bar": "true"} chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie_1, **kwargs) extra_serie_2 = { "tooltip": { "y_start": "$ ", "y_end": "" }, "date_format": "%d %b %Y", } chart.add_serie(name="serie 2", y=ydata2, x=xdata, extra=extra_serie_2) chart.buildhtml()
""" Examples for Python-nvd3 is a Python wrapper for NVD3 graph library. NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js gives you. Project location : https://github.com/areski/python-nvd3 """ from nvd3 import linePlusBarWithFocusChart #Open File for test output_file = open('test_linePlusBarWithFocusChart_AMPM.html', 'w') #--------------------------------------- type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, x_is_date=False, x_axis_format="AM_PM") chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = [i for i in range(0, 24)] ydata = [ 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12 ] ydata2 = [ 9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1 ] ydata3 = [ 9, 8, 15, 8, 4, 7, 20, 8, 4, 6, 0, 4, 5, 7, 3, 15, 30, 6, 3, 1, 0, 0, 0, 1 ] extra_serie_1 = {
kwargs3 = {'shape': 'triangle-up', 'size': '100'} extra_serie = {"tooltip": {"y_start": "", "y_end": " calls"}} chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie, **kwargs1) chart.add_serie(name="serie 2", y=ydata2, x=xdata, extra=extra_serie, **kwargs2) chart.add_serie(name="serie 3", y=ydata3, x=xdata, extra=extra_serie, **kwargs3) chart.buildcontent() output_file.write(chart.htmlcontent) #-------------------------------------------- nb_element = 200 type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, height=350, date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [i + random.randint(10, 20) for i in reversed(list(range(nb_element)))] kwargs = {} kwargs['bar'] = True extra_serie = {"tooltip": {"y_start": "$ ", "y_end": ""}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie, **kwargs) extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent()
chart.add_serie(name="serie 3", y=ydata3, x=xdata, extra=extra_serie, **kwargs3) chart.buildcontent() output_file.write(chart.htmlcontent) #-------------------------------------------- nb_element = 200 type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(height=350, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [ i + random.randint(10, 20) for i in reversed(list(range(nb_element))) ] kwargs = {} kwargs['bar'] = True extra_serie = {"tooltip": {"y_start": "$ ", "y_end": ""}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie, **kwargs) extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie)
""" from nvd3 import linePlusBarWithFocusChart import random import datetime import time start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 #Open File for test output_file = open('test_linePlusBarWithFocusChart.html', 'w') #--------------------------------------- type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, color_category='category20b', date=True, x_axis_format="%d %b %Y") chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(-10, 10) for i in range(nb_element)] ydata2 = [200 - i + random.randint(-10, 10) for i in range(nb_element)] extra_serie_1 = { "tooltip": {"y_start": "$ ", "y_end": ""}, "date_format": "%d %b %Y", } kwargs = {"bar": "true"} chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie_1, **kwargs)
kwargs3 = {'shape': 'triangle-up', 'size': '100'} extra_serie = {"tooltip": {"y_start": "", "y_end": " calls"}} chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie, **kwargs1) chart.add_serie(name="serie 2", y=ydata2, x=xdata, extra=extra_serie, **kwargs2) chart.add_serie(name="serie 3", y=ydata3, x=xdata, extra=extra_serie, **kwargs3) chart.buildcontent() output_file.write(chart.htmlcontent) #-------------------------------------------- nb_element = 200 type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(height=350, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [i + random.randint(10, 20) for i in reversed(list(range(nb_element)))] kwargs = {} kwargs['bar'] = True extra_serie = {"tooltip": {"y_start": "$ ", "y_end": ""}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie, **kwargs) extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent()
""" from nvd3 import linePlusBarWithFocusChart import random import datetime import time start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 #Open File for test output_file = open('test_linePlusBarWithFocusChart.html', 'w') #--------------------------------------- type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, color_category='category20b', x_is_date=True, x_axis_format="%d %b %Y") chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(-10, 10) for i in range(nb_element)] ydata2 = [200 - i + random.randint(-10, 10) for i in range(nb_element)] extra_serie_1 = { "tooltip": { "y_start": "$ ", "y_end": "" }, "date_format": "%d %b %Y",
""" Examples for Python-nvd3 is a Python wrapper for NVD3 graph library. NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js gives you. Project location : https://github.com/areski/python-nvd3 """ from nvd3 import linePlusBarWithFocusChart #Open File for test output_file = open('test_linePlusBarWithFocusChart_AMPM.html', 'w') #--------------------------------------- type = "linePlusBarWithFocusChart" chart = linePlusBarWithFocusChart(name=type, x_is_date=False, x_axis_format="AM_PM") chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") xdata = [i for i in range(0, 24)] ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12] ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1] ydata3 = [9, 8, 15, 8, 4, 7, 20, 8, 4, 6, 0, 4, 5, 7, 3, 15, 30, 6, 3, 1, 0, 0, 0, 1] extra_serie_1 = { "tooltip": {"y_start": "$ ", "y_end": ""}, "date_format": "", } kwargs = {"bar": "true"} chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie_1, **kwargs)