using Highcharts library with Polymer

1,179 views
Skip to first unread message

satyasrik...@gmail.com

unread,
Jan 10, 2014, 3:36:34 AM1/10/14
to polym...@googlegroups.com
Hello,

I need to create a reusable element for a pie-chart. After trying I noticed that the charts are deformed. 

This is the polymer element I am using.

<link rel="import" href="../bower_components/polymer/polymer.html">

<polymer-element name="chart-pie">
    <template>
        <div id="container" style="min-width: 100%; height: 360px;"></div>
    </template>
    <script>
        Polymer("chart-pie", {
            url: "",
            datum: [
                            ['Low', 45.0],
                            ['Medium', 26.8],
                            {
                                name: 'High',
                                y: 12.8,
                                sliced: true,
                                selected: true
                            }
            ],
            ready: function () {
                var options = {
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false,
                        renderTo: this.$.container
                    },
                    title: {
                        text: 'Incident Severity'
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                color: '#000000',
                                connectorColor: '#000000',
                                format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                            }
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: 'Severity',
                        data: this.datum
                    }]
                };
                //$("container").highcharts(options);
                //this.$.container.highcharts(options);
                var chart = new Highcharts.Chart(options);

            }
        });
    </script>
</polymer-element>

Any help would be appreciated.

Kind regards,
Satya.


satyasrik...@gmail.com

unread,
Jan 10, 2014, 4:08:37 AM1/10/14
to polym...@googlegroups.com, satyasrik...@gmail.com
Update Please check the jsbin

Daniel Freedman

unread,
Jan 10, 2014, 2:45:34 PM1/10/14
to satyasrik...@gmail.com, polymer-dev
Taking a look at this now. Seems to be related to the ShadowDOM Polyfill, as native ShadowDOM renders the chart correctly.


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Daniel Freedman

unread,
Jan 10, 2014, 4:18:45 PM1/10/14
to satyasrik...@gmail.com, polymer-dev, Erik Arvidsson
I've studied this for a bit now, and I have a hunch that the problem is related to some incorrect sizing, either due to a stale SD polyfill wrapper property, or jquery doing some funky math based on DOM properties that the SD Polyfill doesn't wrap "correctly".

Either way, I waded into the depths of the Highchart library, but couldn't find the point where the measurements from native ShadowDOM and polyfill differ. There's a lot of code in there.

@arv: I'm guessing there's probably a better way to try and instrument this, but I'm fresh outta steam. Any ideas?

Erik Arvidsson

unread,
Jan 10, 2014, 4:19:22 PM1/10/14
to Daniel Freedman, satyasrik...@gmail.com, polymer-dev
I've been looking at this for some time now.

I found a case where we are calling `wrapper.getBBox()` but `wrapper.getBBox` is not wrapped so it tries to invoke the native method on the wrapper which fails and the user code returns a bounding box of {0,0} which seems to explain some of the incorrect sizings.
--
erik


Erik Arvidsson

unread,
Jan 10, 2014, 4:22:47 PM1/10/14
to Daniel Freedman, satyasrik...@gmail.com, polymer-dev
Look for `try { a = c.getBBox`
--
erik


Daniel Freedman

unread,
Jan 10, 2014, 4:40:04 PM1/10/14
to Erik Arvidsson, satya srikant mantha, polymer-dev
This seems to work as expected with https://github.com/Polymer/ShadowDOM/pull/343.

The next stable release (0.1.3) should have this fixed.

satyasrik...@gmail.com

unread,
Jan 11, 2014, 10:22:27 PM1/11/14
to polym...@googlegroups.com, Erik Arvidsson, satya srikant mantha
Thanks Guys, 

Will wait for the new build.

kunalc...@gmail.com

unread,
Jul 14, 2014, 8:41:42 AM7/14/14
to polym...@googlegroups.com, satyasrik...@gmail.com
Thank you, its work for other highchart..., But for bubble high chart its not working......please help me!!!!


On Friday, 10 January 2014 14:06:34 UTC+5:30, satyasrik...@gmail.com wrote:

avdar...@gmail.com

unread,
Mar 14, 2016, 2:20:42 PM3/14/16
to Polymer, satyasrik...@gmail.com, kunalc...@gmail.com
You can use highcharts-chart Polymer Component to plot charts with just one line.

This would be your final output
<highcharts-chart type="pie" data="[[pieData]]" title="My Pie Chart"></highcharts-chart>

There's a demo here and here.


Polymer Component to plot charts with just one line.

maha.be...@telecomnancy.net

unread,
Aug 2, 2016, 4:19:26 PM8/2/16
to Polymer, satyasrik...@gmail.com
Hi, 
I've been trying to figure out how to use highchart-chart to come up with a chart similar to this 
but Ican't figure it out please lend me some help, here's what I've tried
<highcharts-chart id="Chart" x-Axis='["Jan", "Feb", "Mar"]' type="spline" title="Monthly Average Temperature" subtitle="Source: WorldClimate.com" x-label="Months"  y-label="Average"
        y-Axis='{name= "Tokyo", series= [7.0, 6.9, 9.5]},
        {name= "New York", series= [-0.2, 0.8, 5.7},
        {name= "Berlin", series= [-0.9, 0.6, 3.5]},
        {name= "London", series= [3.9, 4.2, 5.7}'></highcharts-chart>
best regards,
BENJEBARA Maha

 

avdar...@gmail.com

unread,
Aug 6, 2016, 4:09:32 PM8/6/16
to Polymer, satyasrik...@gmail.com, maha.be...@telecomnancy.net
Your JSON seems to be completely invalid, you would be able to see that error in your console. Additionally, it's x-axis (not x-Axis) since all props are actually case sensitive. According to the highcharts api, you need to have x-axis: {categories: ["Jan","Feb","Mar"]}. Also the data should NEVER go in the y-axis property, rather it should be in the data key. All in all, your new HTML looks like this:

<highcharts-chart id="Chart" x-Axis='{"categories": ["Jan", "Feb", "Mar"]}' type="spline" title="Monthly Average Temperature" subtitle="Source: WorldClimate.com" x-label="Months"  y-label="Average"
        data='[{"name": "Tokyo", "data": [7.0, 6.9, 9.5]},
        {"name": "New York", "data": [-0.2, 0.8, 5.7]},
        {"name": "Berlin", "data": [-0.9, 0.6, 3.5]},
        {"name": "London", "data": [3.9, 4.2, 5.7]}]'></highcharts-chart>


PS. Please post any concerns in the issues tab in the Github Repo/Stack Overflow, as it may help fellow developers with similar issues. Thanks

Sincerely,
AP [highcharts-chart author]
Reply all
Reply to author
Forward
0 new messages