<commit_before><?php

use app\assets\BookInfoStatAsset;

use yii\helpers\Html;


BookInfoStatAsset::register( $this );

?>
<div class="all">
	<div class="bread-nav">
		<span>图书档案</span> >
		<span>图书信息统计</span>
	</div>
	<?= Html::hiddenInput('jsonData', $data , [ 'class' => 'jsonData' ] ) ?>	


	<button type='button' class='btn btn-primary' > 书架统计 </button>
	<button type='button' class='btn btn-primary' > 书架统计 </button>


	<div class='help-block'></div>
	<div id="container" class='chart' style="min-width: 310px; height: 520px; max-width: 700px; margin: 0 0 0 300px; "></div>	


</div>

<script>
window.onload = function(){
	str  = $('.jsonData').val();
	json = eval("("+ str +")");
	charts( json );

}

function charts( data ){

	options = {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
			plotShadow: false,
			backgroundColor: '#FFFFF0',
			padding: '0px',
        },
        title: {
            text: '图书馆内各书架内的书籍数量在图书馆内的占比'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Browser share',
            data: []
        }]
    }


	// 将php传过来的 json 数据，循环放进 options 对象的 data 里
	for( var i=0; i < data.length; i++ ){
		options.series[0].data[i] = [ data[i].name , data[i].count ];	
	}


	$(function () {
		// 传入上面定义的对象数据 options
		$('#container').highcharts( options	);
	});



}





</script><commit_msg> js 调用双饼图<commit_after><?php

use app\assets\BookInfoStatAsset;

use yii\helpers\Html;


BookInfoStatAsset::register( $this );

?>
<div class="all">
	<div class="bread-nav">
		<span>图书档案</span> >
		<span>图书信息统计</span>
	</div>

	<?= Html::hiddenInput('jsonData', $data , [ 'class' => 'jsonData' ] ) ?>	
	
	<button type='button' class='btn btn-primary' > 书架统计 </button>
	<button type='button' class='btn btn-primary' > 书架统计 </button>


	<div class='help-block'></div>
	<div id="container" class='chart' style="min-width: 310px; height: 520px; max-width: 700px; margin: 0 0 0 300px; "></div>	


</div>

<script>
window.onload = function(){
	str  = $('.jsonData').val();
	json = eval("("+ str +")");
	my();
	//charts( json );
}


function my(){

$(function () {

    var colors = Highcharts.getOptions().colors,
        categories = ['MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera'];

	var data = [{}],
        browserData = [],
        versionsData = [],
        i,
        j,
        dataLen = data.length,
        drillDataLen,
        brightness;





    // Build the data arrays
    for (i = 0; i < json.length; i += 1) {

        browserData.push({
            name: json[i].bookshelfName,
            y: json[i].bookshelfPercent,
            color: colors[i]
        });


        drillDataLen = json[i].subClass.length; 

        for (j = 0; j < drillDataLen; j += 1) {
            brightness = 0.2 - (j / drillDataLen) / 5;
            versionsData.push({
                name: json[i].subClass[j].bookTypeName,
                y: json[i].subClass[j].percent,
                color: Highcharts.Color(browserData[i].color).brighten(brightness).get()
            });
        }
    }

    // Create the chart
    $('#container').highcharts({
        chart: {
            type: 'pie'
        },
        title: {
            text: 'Browser market share, April, 2011'
        },
        yAxis: {
            title: {
                text: 'Total percent market share'
            }
        },
        plotOptions: {
            pie: {
                shadow: false,
                center: ['50%', '50%']
            }
        },
        tooltip: {
            valueSuffix: '%'
        },
        series: [{
            name: 'Browsers',
            data: browserData,
            size: '60%',
            dataLabels: {
                formatter: function () {
                    return this.y > 5 ? this.point.name : null;
                },
                color: 'white',
                distance: -30
            }
        }, {
            name: 'Versions',
            data: versionsData,
            size: '80%',
            innerSize: '60%',
            dataLabels: {
                formatter: function () {
                    // display only if larger than 1
                    return this.y > 1 ? '<b>' + this.point.name + ':</b> ' + this.y + '%'  : null;
                }
            }
        }]
    });
});


}   // function my()





</script>
{'fraction_non_alphanumeric': 0.166598611678236, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 1.661053775122216, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2622526', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1621, 'n_words': 324}