diff --git a/README.md b/README.md index ee94347..b00e4fd 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,22 @@ PHP project to generate clean-looking SVG price charts * PHP ## Installation -Extract the files from https://github.com/seigler/Dash-SVG-chart/archive/master.zip where you want to use the chart, or from the command line run `git clone "https://github.com/seigler/Dash-SVG-chart" .` in the folder where you want the charts served from. +Best: +add a composer dependency on `seigler/neat-charts`. + +Next best: +Copy the how it's done in `/demo/index.php`. ## Usage -In your PHP file: +With Composer: +`composer require seigler/neat-charts` +In your PHP file: ```php date] = $item->weightedAverage; +} + +$poloniexChart = new NeatCharts\LineChart($chartData, [ + 'width'=>800, + 'height'=>200, + 'lineColor'=>"#1C75BC", // Dash blue + 'labelColor'=>"#777", + 'smoothed'=>false, + 'fontSize'=>10 +]); +$svg = $poloniexChart->render(); + +$im = new Imagick(); +$im->setBackgroundColor(new ImagickPixel("transparent")); +$im->readImageBlob($svg); +$im->setImageFormat("png32"); +echo $im; +$im->clear(); +$im->destroy(); diff --git a/src/NeatCharts/LineChart.php b/src/NeatCharts/LineChart.php index 9aae92a..1f045fb 100644 --- a/src/NeatCharts/LineChart.php +++ b/src/NeatCharts/LineChart.php @@ -193,8 +193,8 @@ namespace NeatCharts { // Top and bottom grid labels $gridText = - ''.($this->labelFormat($this->yMax, $labelPrecision + 1)).'' . - ''.($this->labelFormat($this->yMin, $labelPrecision + 1)).''; + ''.($this->labelFormat($this->yMax, $labelPrecision + 1)).'' . + ''.($this->labelFormat($this->yMin, $labelPrecision + 1)).''; // Main labels and grid lines for ( @@ -207,7 +207,7 @@ namespace NeatCharts { $labelHeight < $this->height - 1.5 * $this->options['fontSize'] && $labelHeight > $this->options['fontSize'] * 1.5 ) { - $gridText .= ''.$this->labelFormat($labelY, $labelPrecision).''; + $gridText .= ''.$this->labelFormat($labelY, $labelPrecision).''; $gridLines .= ' M0,'.$labelHeight.' '.$this->width.','.$labelHeight; } else if ( // label is too close $labelHeight < $this->height - $this->options['fontSize'] * 0.75 && @@ -231,40 +231,33 @@ namespace NeatCharts { - - - - '.( $gridText ).' + + + - + + '.( $gridText ).' + +