diff --git a/.gitignore b/.gitignore index 78ecd3eb..c15b2627 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ bower_components archive env +myenv htmlcov test_*.html diff --git a/README.rst b/README.rst index c7022748..667d5ca5 100644 --- a/README.rst +++ b/README.rst @@ -42,8 +42,8 @@ These graphs can be part of your web application: Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:: >>> from nvd3 import pieChart - >>> type = 'pieChart' - >>> chart = pieChart(name=type, color_category='category20c', height=450, width=450) + >>> chart_name = 'pieChart' + >>> chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) >>> xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] >>> ydata = [3, 4, 0, 1, 5, 7, 3] >>> extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/docs/source/includes/introduction.txt b/docs/source/includes/introduction.txt index 414241ec..a1001bfd 100644 --- a/docs/source/includes/introduction.txt +++ b/docs/source/includes/introduction.txt @@ -52,8 +52,8 @@ After installation use python-nvd3 as follows :: # Open File to write the D3 Graph output_file = open('test-nvd3.html', 'w') - type = 'pieChart' - chart = pieChart(name=type, color_category='category20c', height=450, width=450) + chart_name = 'pieChart' + chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] diff --git a/docs/source/index.rst b/docs/source/index.rst index 2915604c..30f22f45 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,8 +25,8 @@ These graphs can be part of your web application: Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:: >>> from nvd3 import pieChart - >>> type = 'pieChart' - >>> chart = pieChart(name=type, color_category='category20c', height=450, width=450) + >>> chart_name = 'pieChart' + >>> chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) >>> xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] >>> ydata = [3, 4, 0, 1, 5, 7, 3] >>> extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/examples/cumulativeLineChart.py b/examples/cumulativeLineChart.py index d0864fd3..c3ecc444 100644 --- a/examples/cumulativeLineChart.py +++ b/examples/cumulativeLineChart.py @@ -21,8 +21,8 @@ # Open File for test output_file = open('test_cumulativeLineChart.html', 'w') -type = "cumulativeLineChart" -chart = cumulativeLineChart(name=type, height=350, x_is_date=True) +chart_name = "cumulativeLineChart" +chart = cumulativeLineChart(name=chart_name, height=350, x_is_date=True) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = list(range(nb_element)) diff --git a/examples/demo_all.py b/examples/demo_all.py index c2c161b4..175542c7 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -45,7 +45,7 @@ output_file.write(html_open) -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='my graphname', height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] @@ -58,8 +58,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "pie Chart" -chart = pieChart(name=type, color_category='category20c', height=400, +chart_name = "pie Chart" +chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -74,7 +74,7 @@ # --------------------------------------- name = "lineChart-different-x-axis" -type = "lineChart" +chart_name = "lineChart" chart = lineChart(name=name, height=400, width=800, x_is_date=False, jquery_on_ready=True) @@ -98,7 +98,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineChart" +chart_name = "lineChart" chart = lineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True) @@ -123,7 +123,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineChartWithInteractiveGuideline" +chart_name = "lineChartWithInteractiveGuideline" chart = lineChart(name="lineChart-With-Interactive-Guideline", height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True, use_interactive_guideline=True) @@ -149,7 +149,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineWithFocusChart" +chart_name = "lineWithFocusChart" chart = lineWithFocusChart(color_category='category20b', x_is_date=True, height=400, width=800, x_axis_format="%d %b %Y", jquery_on_ready=True) @@ -177,7 +177,7 @@ # --------------------------------------- -type = "stackedAreaChart" +chart_name = "stackedAreaChart" chart = stackedAreaChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %I", jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -197,7 +197,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "linePlusBarChart" +chart_name = "linePlusBarChart" chart = linePlusBarChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True, focus_enable=True) @@ -219,7 +219,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "cumulativeLineChart" +chart_name = "cumulativeLineChart" chart = cumulativeLineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) @@ -240,7 +240,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarHorizontalChart" +chart_name = "multiBarHorizontalChart" chart = multiBarHorizontalChart(height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -258,7 +258,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarChart" +chart_name = "multiBarChart" chart = multiBarChart(height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 10 @@ -275,8 +275,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarChartDate" -chart = multiBarChart(name=type, height=400, width=800, x_is_date=True, jquery_on_ready=True) +chart_name = "multiBarChartDate" +chart = multiBarChart(name=chart_name, height=400, width=800, x_is_date=True, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 100 start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) @@ -297,8 +297,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "scatterChart" -chart = scatterChart(name=type, height=350, width=800, x_is_date=False) +chart_name = "scatterChart" +chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index e8ffa29b..952a4f20 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -15,7 +15,7 @@ # Open File for test output_file = open('test_discreteBarChart.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, show_values=True, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] @@ -33,7 +33,7 @@ output_file = open('test_discreteBarChart2.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, tooltips=False) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/discreteBarChart_with_date.py b/examples/discreteBarChart_with_date.py index f8798657..9d6c2fa1 100644 --- a/examples/discreteBarChart_with_date.py +++ b/examples/discreteBarChart_with_date.py @@ -18,7 +18,7 @@ # Open File for test output_file = open('test_discreteBarChart_with_date.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 10 @@ -27,7 +27,7 @@ xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] -chart = discreteBarChart(name=type, height=400, width=600, x_is_date=True, x_axis_format="%d-%b") +chart = discreteBarChart(name=chart_name, height=400, width=600, x_is_date=True, x_axis_format="%d-%b") chart.set_containerheader("\n\n

" + type + "

\n\n") extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/examples/ipythonDemo.ipynb b/examples/ipythonDemo.ipynb index f2f5dd1c..696dda0f 100644 --- a/examples/ipythonDemo.ipynb +++ b/examples/ipythonDemo.ipynb @@ -86,8 +86,8 @@ }, "outputs": [], "source": [ - "type = 'stackedAreaChart'\n", - "chart2 = nvd3.stackedAreaChart(name=type,height=450,width=500, \n", + "chart_name = 'stackedAreaChart'\n", + "chart2 = nvd3.stackedAreaChart(name=chart_name,height=450,width=500, \n", " use_interactive_guideline=True)\n", "nb_element = 50\n", "xdata = range(nb_element)\n", @@ -142,8 +142,8 @@ }, "outputs": [], "source": [ - "type = 'pieChart'\n", - "chart1 = nvd3.pieChart(name=type, color_category='category20c', height=450, width=450)\n", + "chart_name = 'pieChart'\n", + "chart1 = nvd3.pieChart(name=chart_name, color_category='category20c', height=450, width=450)\n", "chart1.set_containerheader(\"\\n\\n

\" + type + \"

\\n\\n\")\n", "\n", "#Create the keys\n", diff --git a/examples/lineChart.py b/examples/lineChart.py index 1dce1b9a..053b7e76 100644 --- a/examples/lineChart.py +++ b/examples/lineChart.py @@ -14,8 +14,8 @@ # Open File for test output_file = open('test_lineChart.html', 'w') # --------------------------------------- -type = "lineChart" -chart = lineChart(name=type, x_is_date=False, x_axis_format="AM_PM") +chart_name = "lineChart" +chart = lineChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = list(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] diff --git a/examples/lineChartXY.py b/examples/lineChartXY.py index f74a1a9a..1e8ae2d8 100644 --- a/examples/lineChartXY.py +++ b/examples/lineChartXY.py @@ -14,8 +14,8 @@ output_file = open('test_lineChartXY.html', 'w') -type = "lineChart" -chart = lineChart(name=type, x_is_date=False, +chart_name = "lineChart" +chart = lineChart(name=chart_name, x_is_date=False, x_axis_format=".1f", y_axis_format=".1f", width=500, height=500, show_legend=False) diff --git a/examples/linePlusBarChart.py b/examples/linePlusBarChart.py index 3dbeba71..e1d38265 100644 --- a/examples/linePlusBarChart.py +++ b/examples/linePlusBarChart.py @@ -20,8 +20,8 @@ output_file = open('test_linePlusBarChart.html', 'w') -type = "linePlusBarChart" -chart = linePlusBarChart(name=type, height=350, width=750, +chart_name = "linePlusBarChart" +chart = linePlusBarChart(name=chart_name, height=350, width=750, x_is_date=True, x_axis_format="%d %b %Y", focus_enable=True) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/lineWithFocusChart.py b/examples/lineWithFocusChart.py index 7d765019..8e14f700 100644 --- a/examples/lineWithFocusChart.py +++ b/examples/lineWithFocusChart.py @@ -21,8 +21,8 @@ # Open File for test output_file = open('test_lineWithFocusChart.html', 'w') # --------------------------------------- -type = "lineWithFocusChart" -chart = lineWithFocusChart(name=type, height=550, width=850, +chart_name = "lineWithFocusChart" +chart = lineWithFocusChart(name=chart_name, height=550, width=850, color_category='category20b', x_is_date=True, x_axis_format="%d %b %Y %H", focus_enable=True) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/multiBarChart.py b/examples/multiBarChart.py index f914a356..96752284 100644 --- a/examples/multiBarChart.py +++ b/examples/multiBarChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_multiBarChart.html', 'w') -type = "multiBarChart" -chart = multiBarChart(name=type, height=350) +chart_name = "multiBarChart" +chart = multiBarChart(name=chart_name, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") chart.callback = ''' function(){ diff --git a/examples/multiBarChart_date.py b/examples/multiBarChart_date.py index afd5ff02..b1557e0a 100644 --- a/examples/multiBarChart_date.py +++ b/examples/multiBarChart_date.py @@ -17,9 +17,9 @@ # Open File for test output_file = open('test_multiBarChart_date.html', 'w') -type = "multiBarChart" +chart_name = "multiBarChart" -chart = multiBarChart(name=type, height=350, x_is_date=True) +chart = multiBarChart(name=chart_name, height=350, x_is_date=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 100 diff --git a/examples/multiBarHorizontalChart.py b/examples/multiBarHorizontalChart.py index c8b5c790..84d2e41e 100644 --- a/examples/multiBarHorizontalChart.py +++ b/examples/multiBarHorizontalChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_multiBarHorizontalChart.html', 'w') -type = "multiBarHorizontalChart" -chart = multiBarHorizontalChart(name=type, height=350) +chart_name = "multiBarHorizontalChart" +chart = multiBarHorizontalChart(name=chart_name, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 10 diff --git a/examples/multiChart.py b/examples/multiChart.py index 501c2044..f1960e5c 100644 --- a/examples/multiChart.py +++ b/examples/multiChart.py @@ -14,8 +14,8 @@ # Open File for test output_file = open('test_multiChart.html', 'w') # --------------------------------------- -type = "multiChart" -chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") +chart_name = "multiChart" +chart = multiChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = [1,2,3,4,5,6] ydata = [115.5,160.5,108,145.5,84,70.5] diff --git a/examples/pieChart.py b/examples/pieChart.py index 3e208a6b..e192b436 100644 --- a/examples/pieChart.py +++ b/examples/pieChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_pieChart.html', 'w') -type = "pieChart" -chart = pieChart(name=type, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") +chart_name = "pieChart" +chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") chart.set_containerheader("\n\n

" + type + "

\n\n") chart.callback = ''' function(){ diff --git a/examples/scatterChart.py b/examples/scatterChart.py index 51338907..d58d8522 100644 --- a/examples/scatterChart.py +++ b/examples/scatterChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_scatterChart.html', 'w') -type = "scatterChart" -chart = scatterChart(name=type, height=350, width=800, x_is_date=False) +chart_name = "scatterChart" +chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py index 6805ff07..867c2e1a 100644 --- a/nvd3/bulletChart.py +++ b/nvd3/bulletChart.py @@ -22,7 +22,7 @@ class bulletChart(TemplateMixin, NVD3Chart): Python example: from nvd3.bulletChart import bulletChart - chart = bulletChart.bulletChart(name=type, height=100, width=500) + chart = bulletChart.bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'US$, in thousands' ranges = [150, 225, 300] diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py index f94bb9b5..2880fd82 100644 --- a/nvd3/multiChart.py +++ b/nvd3/multiChart.py @@ -20,8 +20,8 @@ class multiChart(TemplateMixin, NVD3Chart): Python example:: from nvd3 import multiChart - type = "multiChart" - chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") + chart_name = "multiChart" + chart = multiChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = [1,2,3,4,5,6] ydata = [115.5,160.5,108,145.5,84,70.5] diff --git a/tests.py b/tests.py index 63b73c70..2e7c64fe 100644 --- a/tests.py +++ b/tests.py @@ -32,8 +32,8 @@ def test_chartWithBadName(self): def test_lineWithFocusChart(self): """Test Line With Focus Chart""" - type = "lineWithFocusChart" - chart = lineWithFocusChart(name=type, date=True, height=350) + chart_name = "lineWithFocusChart" + chart = lineWithFocusChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -45,8 +45,8 @@ def test_lineWithFocusChart(self): def test_lineChart(self): """Test Line Chart""" - type = "lineChart" - chart = lineChart(name=type, date=True, height=350) + chart_name = "lineChart" + chart = lineChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -61,8 +61,8 @@ def test_lineChart(self): def test_lineChart_tooltip(self): """Test Line Chart""" - type = "lineChart" - chart = lineChart(name=type, date=True, height=350) + chart_name = "lineChart" + chart = lineChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -83,8 +83,8 @@ def test_lineChart_tooltip(self): def test_linePlusBarChart(self): """Test line Plus Bar Chart""" - type = "linePlusBarChart" - chart = linePlusBarChart(name=type, date=True, height=350) + chart_name = "linePlusBarChart" + chart = linePlusBarChart(name=chart_name, date=True, height=350) start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 xdata = list(range(nb_element)) @@ -99,8 +99,8 @@ def test_linePlusBarChart(self): def test_stackedAreaChart(self): """Test Stacked Area Chart""" - type = "stackedAreaChart" - chart = stackedAreaChart(name=type, height=400) + chart_name = "stackedAreaChart" + chart = stackedAreaChart(name=chart_name, height=400) nb_element = 100 xdata = list(range(nb_element)) xdata = [100 + x for x in xdata] @@ -112,8 +112,8 @@ def test_stackedAreaChart(self): def test_MultiBarChart(self): """Test Multi Bar Chart""" - type = "MultiBarChart" - chart = multiBarChart(name=type, height=400) + chart_name = "MultiBarChart" + chart = multiBarChart(name=chart_name, height=400) nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(1, 10) for i in range(nb_element)] @@ -123,9 +123,9 @@ def test_MultiBarChart(self): def test_multiChart(self): """Test Multi (line plus bar) Chart""" - type = "multiChart" + chart_name = "multiChart" chart = multiChart( - name=type, x_is_date=False, x_axis_format="AM_PM", + name=chart_name, x_is_date=False, x_axis_format="AM_PM", no_data_message='custom message shows when there is no data', xAxis_staggerLabel=True ) @@ -147,8 +147,8 @@ def test_multiChart(self): def test_multiBarHorizontalChart(self): """Test multi Bar Horizontal Chart""" - type = "multiBarHorizontalChart" - chart = multiBarHorizontalChart(name=type, height=350) + chart_name = "multiBarHorizontalChart" + chart = multiBarHorizontalChart(name=chart_name, height=350) nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] @@ -159,8 +159,8 @@ def test_multiBarHorizontalChart(self): def test_cumulativeLineChart(self): """Test Cumulative Line Chart""" - type = "cumulativeLineChart" - chart = cumulativeLineChart(name=type, height=400) + chart_name = "cumulativeLineChart" + chart = cumulativeLineChart(name=chart_name, height=400) start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 xdata = list(range(nb_element)) @@ -173,8 +173,8 @@ def test_cumulativeLineChart(self): def test_scatterChart(self): """Test Scatter Chart""" - type = "scatterChart" - chart = scatterChart(name=type, date=True, height=350) + chart_name = "scatterChart" + chart = scatterChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = [i + random.randint(1, 10) for i in range(nb_element)] ydata = [i * random.randint(1, 10) for i in range(nb_element)] @@ -191,8 +191,8 @@ def test_scatterChart(self): def test_discreteBarChart(self): """Test discrete Bar Chart""" - type = "discreteBarChart" - chart = discreteBarChart(name=type, height=350) + chart_name = "discreteBarChart" + chart = discreteBarChart(name=chart_name, height=350) xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 35, -7, 2] @@ -205,8 +205,8 @@ def test_discreteBarChart(self): def test_pieChart(self): """Test Pie Chart""" - type = "pieChart" - chart = pieChart(name=type, color_category='category20c', height=400, width=400) + chart_name = "pieChart" + chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400) xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] color_list = ['orange', 'yellow', '#C5E946', '#95b43f', 'red', '#FF2259', '#F6A641'] extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}, "color_list": color_list} @@ -218,16 +218,16 @@ def test_pieChart(self): def test_donutPieChart(self): """Test Donut Pie Chart""" - type = "pieChart" - chart = pieChart(name=type, height=400, width=400, donut=True, donutRatio=0.2) + chart_name = "pieChart" + chart = pieChart(name=chart_name, height=400, width=400, donut=True, donutRatio=0.2) xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] ydata = [3, 4, 0, 1, 5, 7, 3] chart.add_serie(y=ydata, x=xdata) chart.buildhtml() def test_can_create_bulletChart(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'US$, in thousands' ranges = [150, 225, 300] @@ -242,8 +242,8 @@ def test_can_create_bulletChart(self): chart.buildhtml() def test_bulletChart_htmlcontent_correct(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'USD, in mill' ranges = [100, 250, 300] @@ -262,8 +262,8 @@ def test_bulletChart_htmlcontent_correct(self): assert 'nv.models.bulletChart();' in chart.htmlcontent def test_bulletChart_marker_optional(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'USD, in mill' ranges = [100, 250, 300] @@ -282,18 +282,18 @@ def test_bulletChart_marker_optional(self): def test_charts_with_extras(self): # extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)" type_bullet = 'bulletChart' - bullet_chart = bulletChart(name=type_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") + bullet_chart = bulletChart(name=chart_name_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") bullet_chart.buildhtml() assert 'data_bulletchart' in bullet_chart.htmlcontent assert "d3.selectAll('#mygraphname text').style('opacity', 0.5)" in bullet_chart.htmlcontent type_pie = "pieChart" - pie_chart = pieChart(name=type_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") + pie_chart = pieChart(name=chart_name_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") pie_chart.buildhtml() assert "alert('Example of extra not even related to d3!')" in pie_chart.htmlcontent type_line_plus_bar = "linePlusBarChart" - line_plus_bar_chart = linePlusBarChart(name=type_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") + line_plus_bar_chart = linePlusBarChart(name=chart_name_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") line_plus_bar_chart.buildhtml() assert "d3.selectAll('#mygraphname text').style('fill', 'red')" in line_plus_bar_chart.htmlcontent