मैं एक बहुलक Highcharts तत्व यह है कि काम करता है से अधिक:पॉलिमर खाका दोहराएँ एकाधिक चार्ट
{
"categories": ["Muriel E Bowser", "Tommy Wells", "Jack Evans", "Vincent C Gray", "David Catania", "Andy Shallal", "Reta Jo Lewis", "Carol Schwartz", "Vincent Orange", "Christian Carter", "Nestor DJonkam", "Bruce Majors", "Michael L Green"],
"series": [2505, 1654, 1332, 956, 699, 399, 183, 81, 72, 3, 3, 2, 1],
"title": "Mayor (2014)",
"subtitle": "Grassroots Contributors",
"yAxistitle": "Number of DC Residents Contributing to Candidate"
}
और मैं:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="bower_components/polymer/polymer.html">
<polymer-element name="bar-chart" attributes="source">
<template>
<div id="container" style="max-width: 600px; height: 360px;"></div>
</template>
<script>
Polymer("bar-chart", {
ready: function() {
var options = {
chart: {type: 'bar', renderTo: this.$.container},
title: {text: ''},
subtitle: {text: ''},
xAxis: {categories: []},
yAxis: {title: {text: ''}},
plotOptions: {bar: {dataLabels: {enabled: true}}},
legend: {enabled: false},
credits: {enabled: false},
series: [{}]
};
$.getJSON(this.source).done(function(chartjson) {
options.xAxis.categories = chartjson.categories;
options.series[0].data = chartjson.series;
options.title.text = chartjson.title;
options.subtitle.text = chartjson.subtitle;
options.yAxis.title.text = chartjson.yAxistitle;
var chart = new Highcharts.Chart(options);
});
}
});
</script>
</polymer-element>
<bar-chart source="json/grass-roots/2014 Mayor.json"></bar-chart>
मैं '2014 Mayor.json' फ़ाइल के माध्यम से यह कुछ अच्छा डेटा पास एक चार्ट प्राप्त करें।
लेकिन मैं वास्तव में क्या करना चाहता हूं चार्ट चार्ट की एक सरणी पर एकाधिक चार्ट बनाने के लिए पुनरावृत्त है। मैंने यह पता लगाने के लिए बहुत मेहनत की है कि टेम्पलेट दोहराना कैसे काम करता है, लेकिन मैं पॉलिमर और जावास्क्रिप्ट दोनों के लिए नया हूं, और इसे क्रैक करने में सक्षम नहीं हूं।
[
{
"categories": ["Phil Mendelson", "Kris Hammond", "John C Cheeks"], "series": [172, 44, 4],
"title": "Council Chairman (2014)",
"subtitle": "Grassroots Contributors",
"yAxistitle": "Number of DC Residents Contributing to Candidate"
},
{
"categories": ["Muriel E Bowser", "Tommy Wells", "Jack Evans", "Vincent C Gray", "David Catania", "Andy Shallal", "Reta Jo Lewis", "Carol Schwartz", "Vincent Orange", "Christian Carter", "Nestor DJonkam", "Bruce Majors", "Michael L Green"],
"series": [2505, 1654, 1332, 956, 699, 399, 183, 81, 72, 3, 3, 2, 1],
"title": "Mayor (2014)",
"subtitle": "Grassroots Contributors",
"yAxistitle": "Number of DC Residents Contributing to Candidate"
}
]
मैं उस पर कैसे पुनरावृति टेम्पलेट दोहराने का उपयोग कर एक से अधिक चार्ट निर्माण करने के लिए है:
के अपने डेटा फ़ाइल, 'arrayofdata.json' मान लीजिए उस में निम्नलिखित है?
उपयोग किया जा सकता है ... https://blog.polymer-project.org/howto/2014/09/11/template-is-autobinding/ –