【问题标题】:Razorflow Php error :A non well formed numeric value encounteredRazorflow Php 错误:遇到格式不正确的数值
【发布时间】:2019-11-17 16:35:45
【问题描述】:

RazorFlow PHP 是一个 PHP 框架,可用于构建交互式数据驱动仪表板,可在 PC、Mac、平板电脑和智能手机上运行。 razorflow php 中提供了 11 个演示项目。这是其中之一。我想知道它是如何工作的。我检查了 razorflow.php 和 $dataSource 的路径。

<?php
require "../razorflow.php";
Dashboard::setTitle("Drill-down in same chart");

$dataSource = new SQLiteDataSource("databases/birt.sqlite");
$dataSource->setSQLSource("payments JOIN customers ON payments.customerNumber = customers.customerNumber");

$drillCategory = new ChartComponent();
$drillCategory->setWidth(4);
$drillCategory->setCaption("Drill-down by category", "Sales for {{value}}");
$drillCategory->setYAxis("Sales", array('numberPrefix' => "$"));
$drillCategory->setDataSource($dataSource);
$drillCategory->setLabelExpression("Location", "customers.country", array(
    'drillPath' => array('customers.country', 'customers.state', 'customers.city', 'customers.customerName')
));
$drillCategory->addSeries("Sales", "payments.amount", array(
    'displayType' => 'Column'
));
Dashboard::addComponent($drillCategory);

$drillTime = new ChartComponent();
$drillTime->setCaption("Drill-down by time", "Sales for {{value}}");
$drillTime->setYAxis("Sales", array('numberPrefix' => "$"));
$drillTime->setWidth(4);
$drillTime->setDataSource($dataSource);
$drillTime->setLabelExpression("Time", "payments.paymentDate", array(
    'timestampRange' => true,
    'autoDrill' => true
));
$drillTime->addSeries("Sales", "payments.amount", array(
    'displayType' => 'Column'
));
Dashboard::addComponent($drillTime);

Dashboard::Render();

但是,我无法成功运行此代码。它总是以这个错误结束。

消息: 遇到一个格式不正确的数值 Trace: C:\xampp\htdocs\rf_4\core\internal\RFDbDataSource.php:86 C:\xampp\htdocs\rf_4\demos\chart_drilldown1.php:6

提前致谢。

【问题讨论】:

    标签: php dashboard


    【解决方案1】:
     $totalTime = microtime() - $startTime;
    

    错误(遇到格式不正确的数值)参考上面RFDbDataSource.php中的代码行。

    Microtime 返回当前的 Unix 时间戳,单位为微秒。

    microtime() 参数的默认值为 false。以真假为参数值的微时间结果:

    microtime()     - as string 
    microtime(true) - as float
    

    由于,我们对 microtime() 值进行减法运算。 microtime() 应该是浮点数或数字。所以,将microtime() 更改为microtime(true) 能够解决错误(遇到格式不正确的数值)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 2013-05-27
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      相关资源
      最近更新 更多