| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <script src="lib/simpleRequire.js"></script> |
| <script src="lib/config.js"></script> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| </head> |
| <body> |
| <style> |
| #main0 { |
| width: 100%; |
| height: 1000px; |
| margin: 20px 0; |
| } |
| </style> |
| <h3>Pie series label rotate</h3> |
| <div id="main0"></div> |
| <script> |
| |
| require(['echarts'], function (echarts) { |
| function setPieChart() { |
| var positions = [ |
| 'inner', 'center', 'outside' |
| ]; |
| var rotates = [ |
| undefined, |
| 'radial', |
| 'tangential', |
| 30 |
| ]; |
| |
| var chart = echarts.init(document.getElementById('main0')); |
| var rows = positions.length; |
| var cols = rotates.length; |
| |
| var series = []; |
| var title = []; |
| for (var i = 0; i < rows; ++i) { |
| for (var j = 0; j < cols; ++j) { |
| series.push({ |
| type: 'pie', |
| data: [ |
| 2, |
| 1.2, |
| 2.4, |
| 3.6 |
| ], |
| label: { |
| show: true, |
| position: positions[i], |
| rotate: rotates[j], |
| formatter: 'value: {c}', |
| borderColor: '#0ff', |
| borderWidth: 2 |
| }, |
| center: [ |
| 100 / cols * (j + 0.5) + '%', |
| 100 / rows * (i + 0.5) + '%' |
| ], |
| radius: [ |
| 30, |
| 100 / rows * 0.6 + '%' |
| ] |
| }); |
| var rotText = j === 3 ? '30°' : rotates[j]; |
| title.push({ |
| text: positions[i] + ', rotate: ' + rotText, |
| left: 100 / cols * (j + 0.5) + '%', |
| top: 100 / rows * (i + 0.92) + '%', |
| textAlign: 'center' |
| }); |
| } |
| } |
| |
| chart.setOption({ |
| title: title, |
| tooltip: {}, |
| series: series, |
| backgroundColor: '#fff', |
| animation: 0 |
| }); |
| } |
| setPieChart(); |
| }); |
| </script> |
| </body> |
| </html> |