Highchart-piechart:点击

时间:2017-05-26 08:06:57

标签: php symfony highcharts hyperlink

在网上花了很长时间找到问题的答案后,我写这篇文章是因为我没有发现任何问题。我在我的网站上使用highchart来实现从我的数据库中提取的数据的一些饼图。我有很好的折扣图,但我想,如果可以的话,当我们点击饼图的一部分时,我们会被重定向到另一个HTML页面。例如,我们得到了一个饼图,向公司展示了公司销售的数量(%):40%:电脑,40%:汽车和20%食品就像例子(完全错误的例子我只是...寻找方法)。然后,如果我们点击40%汽车的切片,我们会被重定向到另一个页面,向我们展示购买汽车的例子。

这实际上是我的PHP代码来实现这个:

public function accueilAction()
{

    $repository = $this->getDoctrine()->getManager()->getRepository('PharmagestsiteBundle:Pharmacie');

    $pharma = $repository->findAll();
    $avecdex = 0;
    $toutesph = 0;
    foreach ($pharma as $pharmacie) {
        $total =
            $pharmacie->getExtractionDexter();
        if ($total == 1) {
            $avecdex += 1;
        }
        $toutesph++;
    }
    $data = [
        ['Pharmacie avec <br> Dexter installé', $avecdex, $url = "localhost/projet/web/app_dev.php/pharmacie"],
        ['Pharmacie sans <br> Dexter installé', $toutesph - $avecdex],
    ];
    $ob = new Highchart();
    $ob->chart->renderTo('container');
    $ob->chart->type('pie');
    $ob->colors('#006400', '#FF0800');
    $ob->title->text('Pharmacie ayant Dexter installé');

    $ob->title->style(array('fontSize' => '30px','fontFamily' => 'arial'));
    $ob->series(array(array("data" => $data)));

    $ob->plotOptions->pie(array(
        'allowPointSelect' => true,
        'cursor' => 'pointer',
     /*   'point' => ['events' => ['click' => function () {
            window.location.href == this.options.url;
        }
        ]],
        'events' => array('click' => function () {
            window.location.href == "localhost/projet/web/app_dev.php/pharmacie";
        }),*/
        'dataLabels' => array('enabled' => true, 'format' => '{point.name}</b>:<br>{point.percentage:.1f} %', 'style' => array( 'fontSize' => '15px','fontFamily' => 'arial')),
        'style' => array('black'),

    ));

所以我想你明白我想通过localhost / projet / web / app_dev.php / pharmacie重定向

任何帮助甚至建议都会得到认可!

0 个答案:

没有答案
相关问题