我目前使用highcharts并没有为我的项目在传说系列的名称类别组合在一起的要求,但我似乎无法找到一个方法来做到这一点。
有数据系列3“类别”,即PM想已经显示在传奇3列。 最大的问题是,该3类中的一个具有可变数目取决于选择包含在图表中的特征元素。
EG
在一种情况下系列可能是:
苹果,梨,辣椒,黄瓜,甜菜,桔子,土豆,西红柿,萝卜
他们需要显示在像传说:
+------------------------------+
| Apples Tomatoes Beet |
| Oranges Peppers Potatoes |
| Pears Cucumbers Turnips |
+------------------------------+
在另一种情况下,该系列可能是:
西红柿,苹果,橘子,辣椒,黄瓜,土豆,梨
他们需要显示图例所示:
+------------------------------+
| Apples Tomatoes Potatoes |
| Oranges Peppers |
| Pears Cucumbers |
+------------------------------+
有没有办法让这个类型有一系列的变量数字格式的?
这是不可能通过使用默认的API,但你可以创建自定义的传奇,将采取建立一个合适的阵列的照顾。
如何创建一个自定义的传奇例如: http://jsfiddle.net/N3KAC/87/
$(function() { $('#container').highcharts({ title: { text: '' }, legend: { enabled: false }, series: [{ name: 'Potatoes', data: [1, 2, 3, 4, 5] }, { name: 'Tomatoes', data: [7, 6, 5, 4, 3] }] }, function(chart) { $legend = $('#customLegend'); $.each(chart.series, function(j, series) { $legend.append('<div class="item"><div class="symbol" style="background-color:' + series.color + '"></div><div class="serieName" id="">' + series.name + '</div></div>'); }); $('#customLegend .item').click(function() { var inx = $(this).index(), series = chart.series[inx]; if (series.visible) series.setVisible(false); else series.setVisible(true); }); }); });
.symbol { width: 20px; height: 20px; margin-right: 20px; float: left; -webkit-border-radius: 10px; border-radius: 10px; } .serieName { float: left; cursor: pointer; } .item { height: 40px; clear: both; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> <div id="customLegend"></div>