<?php
/**
 * 产品状态
 */
$sql = <<<EOFSQL
SELECT
{:series},
count(DISTINCT sku) sku
FROM gspcatalog_bi.sum_pro_state
WHERE 1
{:where}
GROUP BY {:series}
EOFSQL;

//统计
$countSql = <<<EOFSQL
SELECT
count(DISTINCT sku)
FROM gspcatalog_bi.sum_pro_state
WHERE 1
{:where}
EOFSQL; 

//Max统计

$maxCountSql = <<<EOFSQL
SELECT
count(DISTINCT sku)
FROM gspcatalog_bi.sum_pro
WHERE 1
EOFSQL;

return [
    'options'=>[
        //轴列
        'axis'=>[],
        //维度
        'series'=>['bigcate','cate','year','month','region_s','make','state1','state2'],
        //条件
        'search'=>['year','month','bigcate','cate','region_s','make','state1','state2'],
    ],
    //'order'=>['month'],
    'table'=>'sum_pro_state',
    'sql'=>$sql,
    'fields'=>[
        'axis'=>'',
        'value'=>'sku',
    ],
    'countSql'=>$countSql,
    'maxCountSql'=>$maxCountSql, //其他统计
    //'series'=>'year', //维度
    'echarts'=>[
        'title'=>[
            'text'=>lg('产品状态'),
            'textStyle'=> $style['title']['textStyle'],
        ],
        'tooltip'=>[
            'trigger'=>'item',
            'formatter'=>'{a} <br/>{b} : {c} ({d}%)',
        ],
        'toolbox'=>[
            'feature'=>[
                'dataView'=>['show'=>true,'readOnly'=>true],
                'magicType'=>['show'=>true,'type'=>['pie']],
                'restore'=>['show'=>true],
                'saveAsImage'=>['show'=>true],
            ]
        ],
        'series'=>[
            [
                'name'=>'SKU',
                'data'=>[],
                'type'=>'pie',
                'radius'=>['40%', '70%'],
                'minMargin'=>15,
                'edgeDistance'=>10,
                'lineHeight'=>15,
                'label'=>[
                    'alignTo'=>'edge',
                    'formatter'=> "{name|{b} {d}%}\n{sku|{c}}",
                    'rich'=>['sku'=>['fontSize'=>10,'color'=>'#999']],
                    //'position'=>'center',
                ],
                'labelLine'=>[
                    'length'=>15,
                    'length2'=>0,
                    'maxSurfaceAngle'=>80,
                ],
                'emphasis'=>[
                    'label'=>[
                        'show'=>true,
                        'fontWeight'=>'bold',
                    ],
                ],
            ],
       ]//series
    ],
];