Use highcharts
http://www.highcharts.com

Example:

*ON CONTROLLER*

def chart():

    dados_chart="[{name: 'Batata', y: 12},{name: 'Tomate', y: 8},{name:
'Mamão', y: 12}]" #Change this dynamically

    dados_map={}
    dados_map["dados"]=dados_chart

    chart="""
    <script type="text/javascript">
    Highcharts.setOptions({
        lang:{
        downloadJPEG: "Download em imagem JPG",
        downloadPDF: "Download em documento PDF",
        downloadPNG: "Download em imagem PNG",
        downloadSVG: "Download em vetor SVG",
        loading: "Lendo...",
        noData: "Sem dados para mostrar",
        printChart: "Imprimir Gráfico",
        }
        });

            // Build the chart
            $('#chart').highcharts({
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false,
                    type: 'pie'
                },
                title: {
                    text: 'Meu Gráfico'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: false
                },
                showInLegend: true
            }
        },
        credits:{enabled:false},
        series: [{
            name: 'Vendar por porcentagem',
            colorByPoint: true,
                data: %(dados)s
                }]
            });
    </script>

    """ %dados_map
    return dict(chart=XML(chart))

*ON VIEW*

{{extend 'layout.html'}}
<script src="/YOUR_APP/static/js/highcharts.js"
type="text/javascript"></script>
<script src="/YOUR_APP/static/js/exporting.js"
type="text/javascript"></script>
<div id="chart"></div>
</script>
{{=chart}}

2016-02-15 12:52 GMT-03:00 <rajjmatt...@gmail.com>:

> I used google charts using a simple bar chart since I couldn't find a
> workable example on the slice using pygal etc. But google chart seems
> little slow in loading on the browser and I believe it may be due to
> loading the js file from the remote site. Does anyone have the same
> experience? If so, how did they resolve it. I tried to load the js file
> locally but was unable to make that to work.
>
>
>
> On Monday, January 25, 2016 at 8:32:01 AM UTC-5, Diego Tostes wrote:
>>
>> thanks!
>>
>>
>> 2016-01-22 1:10 GMT-02:00 Junior Phanter <junior...@gmail.com>:
>>
>>> Example using just google chart api, without google-charts-plug-in
>>>
>>> on controller
>>>
>>> def chart():
>>>     title="My Chart"
>>>     data=XML('[ ["item", "value"], ["apple", 1], ["potato", 1.5],
>>> ["watermelon", 0.5]]') #convert list in string and string in XML
>>>     return dict(title=title, data=data)
>>>
>>> on view (chart.html)
>>>
>>> {{extend 'layout.html'}}
>>>
>>> <div id="my_chart" style="width: 900px; height: 500px;
>>> margin:auto;"></div>
>>>
>>> <script type="text/javascript" src="
>>> https://www.gstatic.com/charts/loader.js";></script>
>>>
>>> <script type="text/javascript">
>>>       google.charts.load('current', {'packages':['corechart']});
>>>       google.charts.setOnLoadCallback(drawChart);
>>>       function drawChart() {
>>>
>>>         var data = google.visualization.arrayToDataTable({{=data}});
>>>
>>>         var options = {
>>>           title: '{{=title}}'
>>>         };
>>>
>>>         var chart = new
>>> google.visualization.PieChart(document.getElementById('my_chart'));
>>>
>>>         chart.draw(data, options);
>>>       }
>>> </script>
>>>
>>>
>>> 2016-01-21 18:01 GMT-03:00 Diego Tostes <tostes...@gmail.com>:
>>>
>>>> i am trying to use google chart plugin, but the example at
>>>> http://www.web2pyslices.com/slice/show/1721/google-charts-plugin, it
>>>> is not so clear to me.
>>>>
>>>> anybody can show me a example with a controller and a view?
>>>>
>>>> i need a simple line chart.
>>>>
>>>> rgds
>>>>
>>>> diego
>>>>
>>>> 2016-01-21 17:36 GMT-02:00 Diego Tostes <tostes...@gmail.com>:
>>>>
>>>>> thanks for all!
>>>>>
>>>>>
>>>>> 2016-01-21 14:17 GMT-02:00 Alex <mrau...@gmail.com>:
>>>>>
>>>>>> my favorite chart library:
>>>>>> https://www.amcharts.com/
>>>>>> very beautiful, easy to use, good documentation and friendly license
>>>>>> (allows usage of free version even for commercial websites).
>>>>>>
>>>>>> Alex
>>>>>>
>>>>>> --
>>>>>> Resources:
>>>>>> - http://web2py.com
>>>>>> - http://web2py.com/book (Documentation)
>>>>>> - http://github.com/web2py/web2py (Source code)
>>>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "web2py-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to web2py+un...@googlegroups.com.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>> --
>>>> Resources:
>>>> - http://web2py.com
>>>> - http://web2py.com/book (Documentation)
>>>> - http://github.com/web2py/web2py (Source code)
>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to web2py+un...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to