dqask02082 2013-06-14 23:56
浏览 32

如果在一定百分比以下,则排除价值

I am trying to make a pie chart, using chartjs, to display almost all the data in a database. What it does is count how many times a certain word is used in the database and it uses that count as the value and the word as the name.

In my pie chart I have almost 10 values that are about .01% of the pie chart and i'm trying to remove them.

Anyone have any ideas?

Also google searching this makes it seem like chartjs is not that popular nor supported, would it be more reasonable to use something else?

EDIT:

cakephp MODEL:

function pieChart($conditions = null) {
    //Get Data for PieChart
    $this->RecordDrug->virtualFields['sum'] ='COUNT(*)';
    $records = array();
    $records=$this->RecordDrug->find('list',
        array(
            'conditions' => $conditions,
            'fields' => array( 'Drug.drug', 'sum'),
            'contain' => array( 'Drug', 'Record' ),
            'group'  => 'Drug.Drug'
            ));
    return $records;
}

CONTROLLER:

    $pieChart = $this->Record->pieChart();
    $this->set('output',$pieChart); 

VIEW:

   var pieChartDataSource = [
        <?php
        foreach($output as $compound => $sum){
          echo "{category: '".$compound."', value: ".$sum."}, ";
        }      
        ?>      
    ];
  • 写回答

2条回答 默认 最新

  • doufei1988 2013-06-15 00:01
    关注

    I think what you need is to filter your dataset before calling chartjs to create the chart. Is there any reason not to do that?

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)