Can you please test https://github.com/apache/incubator-airflow/pull/2035 and 
+1 if it works for you.

Thanks
Bolke

> On 30 Jan 2017, at 12:04, Сёмочкин Максим Викторович <[email protected]> wrote:
> 
> I think I found a way to prevent the generation of unnecessary headers in the 
> html code.
> Maybe instead of a chart.buildhtml() will call the method buildcontent()?
> 
> See my example below which shows how it is implemented now in the Airflow and 
> how this can be implemented
> 
> First, prepare a random graph (example taken from the documentation of the 
> module):
> =============================================================
> from nvd3 import lineChart
> chart = lineChart(name="lineChart", x_is_date=False, x_axis_format="AM_PM")
> 
> xdata = range(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]
> 
> extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}}
> chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie)
> extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}}
> chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie)
> =============================================================
> 
> So now use the module in Airflow:
> =============================================================
> chart.buildhtml()
> str(chart)
> 
> Out[62]: '<!DOCTYPE html>\n<html lang="en">\n    <head>\n        <meta 
> charset="utf-8" />\n        <link 
> href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css"; 
> rel="stylesheet" />            
> ....
> ....
> ....
> </body>\n</html>'
> ============================================================= 
> 
> But this way you can generate html code which is guaranteed not to contain we 
> do not need the headers:
> =============================================================
> chart.buildcontent()
> str(chart.content)
> 
> Out[64]: '\n    <div id="linechart"><svg 
> style="height:450px;"></svg></div>\n\n\n    <script>\n\n\n\n            
> data_linechart=[{"values": [{"x": 0, "y": 0}, {"x": 1, "y": 0}, {"x": 2, "y": 
> 1}, {"x": 3, "y": 1}, {"x": 4, "y": 0}, {"x": 5, "y": 0}, {"x": 6, "y": 0}, 
> {"x": 7, "y": 0}, {"x": 8, "y": 1}, {"x": 9, "y": 0}, {"x": 10, "y": 0}, 
> {"x": 11, "y": 4}, {"x": 12, "y": 3}, {"x": 13, "y": 3}, {"x": 14, "y": 5},
> ....
> ....
> ....
> </script>\n'
> =============================================================
> 
> -----Original Message-----
> From: Bolke de Bruin [mailto:[email protected]] 
> Sent: Monday, January 30, 2017 12:52 PM
> To: [email protected]
> Subject: Re: nvd3 is an external resource
> 
> This is in python-nvd3, NVD3Chart.py. Can you please open an issue with them? 
> It seems we can override the setting in Airflow so we can workaround it, but 
> they should fix this.
> 
> Bolke
> 
>> On 30 Jan 2017, at 10:50, Сёмочкин Максим Викторович <[email protected]> wrote:
>> 
>> I checked again and it seems I saw the problem.
>> In the Airflow (more precisely in the Flask) the necessary files are loaded 
>> from the directory static no problem with that.
>> But at some point in the code the method is called chart.buildhtml(), then a 
>> representation of a chart object will become an html that among other things 
>> contains the lines:
>>       <link 
>> href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css"; 
>> rel="stylesheet" />
>>       <script 
>> src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js";></script>
>>       <script 
>> src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.js";></script>
>> 
>> -----Original Message-----
>> From: Bolke de Bruin [mailto:[email protected]] 
>> Sent: Monday, January 30, 2017 11:55 AM
>> To: [email protected]
>> Subject: Re: nvd3 is an external resource
>> 
>> Did you double check btw? The nvd3 libraries are pulled from a local 
>> resources as far as I can see.
>> 
>> - Bolke
>> 
>>> On 30 Jan 2017, at 09:45, Bolke de Bruin <[email protected]> wrote:
>>> 
>>> That is indeed unfortunate. python-nvd3 pulls its in this way (thus not 
>>> Airflow itself). It might be a config thing with them.
>>> 
>>> Bolke
>>> 
>>>> On 30 Jan 2017, at 09:42, Сёмочкин Максим Викторович <[email protected]> 
>>>> wrote:
>>>> 
>>>> Hello!
>>>> Did I understand correctly that version 1.8 is a library for drawing 
>>>> charts (nvd3) is loaded from external resource - cloudflare?
>>>> Our problem is that the Airflow is installed in a closed network segment 
>>>> that has no Internet access
>>> 
>> 
> 

Reply via email to