|
@@ -42,6 +42,16 @@ function drawGraph(data,resultShowId) {
|
|
|
var myChart = echarts.init(document.getElementById('main'));
|
|
|
var categories = data['categories'];
|
|
|
var legends = categories.slice(2, categories.length);
|
|
|
+ var showLegendNum = 0;
|
|
|
+ let sum = 0
|
|
|
+ for(let i = 0; i < legends.length; i++){
|
|
|
+
|
|
|
+ sum += 2+legends[i].name.length+1
|
|
|
+ console.log(sum)
|
|
|
+ if(sum <= 60){
|
|
|
+ showLegendNum ++
|
|
|
+ }
|
|
|
+ }
|
|
|
var option = {
|
|
|
title: {
|
|
|
text: '医学知识图谱',
|
|
@@ -58,11 +68,13 @@ function drawGraph(data,resultShowId) {
|
|
|
type: 'scroll',
|
|
|
bottom: 0,
|
|
|
icon: 'circle',
|
|
|
+ padding:[20, 40, 0, 20],
|
|
|
+ backgroundColor: "#FFFFFF",
|
|
|
// orient: 'vertical',
|
|
|
- // cursor:'pointer',
|
|
|
- data: legends.map(function (a) {
|
|
|
+ data: legends.slice(0,showLegendNum).map(function (a) {
|
|
|
return a.name;
|
|
|
- })
|
|
|
+ }),
|
|
|
+
|
|
|
}],
|
|
|
series: [
|
|
|
{
|
|
@@ -145,8 +157,26 @@ function drawGraph(data,resultShowId) {
|
|
|
})
|
|
|
myChart.on('click',dataClick);
|
|
|
myChart.setOption(option);
|
|
|
-
|
|
|
-}
|
|
|
+ if(legends.length > showLegendNum){
|
|
|
+ $('.legendSlideUp').toggleClass('legendSlideUp')
|
|
|
+ $('.legendIcon').css('display',"block")
|
|
|
+ }else{
|
|
|
+ $('.legendSlideUp').toggleClass('legendSlideUp')
|
|
|
+ $('.legendIcon').css('display',"none")
|
|
|
+ }
|
|
|
+ $('.legendIconImg').on('click',function(){
|
|
|
+ $('.legendIconImg').toggleClass('legendSlideUp')
|
|
|
+ if(option.legend[0].type=='scroll'){
|
|
|
+ option.legend[0].type='plain'
|
|
|
+ option.legend[0].data = legends
|
|
|
+ }else{
|
|
|
+ option.legend[0].type='scroll'
|
|
|
+ option.legend[0].data = legends.slice(0,showLegendNum)
|
|
|
+ }
|
|
|
+
|
|
|
+ myChart.setOption(option);
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
function dataClick(param){
|
|
|
var data = param.data;
|