The character cloud of echarts is displayed garbled




 
 The problem shown in the above figure is because the number of characters appearing in the character set overlaps, resulting in confusion when echarts is displayed. The solution is to redefine the number of occurrences of characters by yourself, define a small interval for the same number of times, and solve the above-mentioned solution if the arithmetic sequence appears.

 

part of the code

 

$arr = array(

"Prado"=>12,

  "system"=>4,

  "Power"=>4,

  "torque"=>4,

  "air bag"=>3,

  "5系"=>3,

  "driver's seat"=>3,

  "Toyota"=>3,

 "mode"=>3,

  "air conditioner"=>2,

  "Pavement"=>2,

  "era"=>2,

  "weather"=>2,

  "temperature" => 2

 

);

Repeat the above data

 

$v_1 = 0; 

$flag_1 = false;

$j = 0.05;

foreach($arr as $k=>$v){

    if($flag_1) $j = 0.05;

    if($v_1 == $v){

       $arr[$k] =  ($v += $j);

        $j += 0.05;

        $flag_1 = false;

    }else{

        $v_1 = $v;

        $flag_1 = true;

    }  

}

echo '<pre>';

arsort ($ arr);

 $arr = array_slice($arr, 0, 14);

print_r($arr);

 

$j is the value of the arithmetic difference of the arithmetic sequence, you can customize this value, make it as small as possible, so that the size of the characters with the same number of times is the same size

 

 

 

Show results:

Array
(
    [prado] => 12
    [torque] => 4.1
    [Power] => 4.05
    [system] => 4
    [mode] => 3.2
    [Toyota] => 3.15
    [driver's seat] => 3.1
    [Series 5] => 3.05
    [airbag] => 3
    [temperature] => 2.2
    [weather] => 2.15
    [era] => 2.1
    [pavement] => 2.05
    [air conditioner] => 2
)

 

At this time, the data is put into echarts for initialization, which solves such a problem.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326754082&siteId=291194637