duanlachu7344 2014-01-24 18:56
浏览 45
已采纳

php Graph将标记更改为100

i have a graph and it's generating well as shown below but i want Marks (Y-axis) to end at 100 instead of 125 enter image description here
Here is the sample index.php

<?php 
    require "chart/chart.php";
        $chart = new KoolChart("chart");
        $chart->scriptFolder="chart";
        $chart->Width = 900;
        $chart->Title->Text = "Student Marks";
        $chart->PlotArea->XAxis->Title = "Tests";
        $chart->PlotArea->XAxis->Set(array("Semester 1","Semester 2","Semester 3"));
        $chart->PlotArea->YAxis->Title = "Marks";
        **$chart->PlotArea->YAxis->LabelsAppearance->DataFormatString = " {0}";**
        $series = new LineSeries();
        $series->Name = "Progess Graph";
        $series->ArrayData(array($test1,$test2,$test3));
     $chart->PlotArea->AddSeries($series);
    ?>

The line in ** ** above is the one responsible for Y-axis.

Here is chart/chart.php http://pastebin.com/96TvRcah

Any help please?

  • 写回答

1条回答 默认 最新

  • douweilei2307 2014-01-24 19:01
    关注

    According to this documentation you need the following:

    $chart->PlotArea->YAxis->MinValue = 0;
    $chart->PlotArea->YAxis->MaxValue = 100;
    $chart->PlotArea->YAxis->MajorStep = 10;
    $chart->PlotArea->YAxis->MinorStep = 2;
    

    So complete code would be:

    <?php 
        require "chart/chart.php";
        $chart = new KoolChart("chart");
        $chart->scriptFolder="chart";
        $chart->Width = 900;
        $chart->Title->Text = "Student Marks";
        $chart->PlotArea->XAxis->Title = "Tests";
        $chart->PlotArea->XAxis->Set(array("Semester 1","Semester 2","Semester 3"));
        $chart->PlotArea->YAxis->Title = "Marks";
        $chart->PlotArea->YAxis->MinValue = 0;
        $chart->PlotArea->YAxis->MaxValue = 100;
        $chart->PlotArea->YAxis->MajorStep = 10;
        $chart->PlotArea->YAxis->MinorStep = 2;
        $chart->PlotArea->YAxis->LabelsAppearance->DataFormatString = " {0}";
        $series = new LineSeries();
        $series->Name = "Progess Graph";
        $series->ArrayData(array($test1,$test2,$test3));
        $chart->PlotArea->AddSeries($series);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)