|
@@ -1,6 +1,7 @@
|
|
SET height = '750';
|
|
SET height = '750';
|
|
SET type = 'line';
|
|
SET type = 'line';
|
|
SET marker = 4;
|
|
SET marker = 4;
|
|
|
|
+SET max_line_series = 50;
|
|
|
|
|
|
SET unit_count_chart = (SELECT v#>>'{}' FROM json_array_elements($unit_count::json) j(v) LIMIT 1);
|
|
SET unit_count_chart = (SELECT v#>>'{}' FROM json_array_elements($unit_count::json) j(v) LIMIT 1);
|
|
SET display_by_count = (SELECT count(*) FROM json_array_elements($unit_count::json) j(v)) == 1
|
|
SET display_by_count = (SELECT count(*) FROM json_array_elements($unit_count::json) j(v)) == 1
|
|
@@ -12,7 +13,14 @@ SELECT 'chart' AS component
|
|
, 'Cost by Weight' AS title
|
|
, 'Cost by Weight' AS title
|
|
, $height AS height
|
|
, $height AS height
|
|
, '$/'||$unit_mass AS ytitle
|
|
, '$/'||$unit_mass AS ytitle
|
|
-, $type AS type
|
|
|
|
|
|
+, CASE
|
|
|
|
+ WHEN (
|
|
|
|
+ SELECT count(DISTINCT product)
|
|
|
|
+ FROM sqlpage_txn
|
|
|
|
+ WHERE unit = $unit_mass
|
|
|
|
+ ) > $max_line_series::numeric
|
|
|
|
+ THEN 'scatter' ELSE $type
|
|
|
|
+ END AS type
|
|
, $log_scale = 'true' AS logarithmic
|
|
, $log_scale = 'true' AS logarithmic
|
|
, TRUE AS time
|
|
, TRUE AS time
|
|
, 0 AS ymin
|
|
, 0 AS ymin
|
|
@@ -30,7 +38,14 @@ SELECT 'chart' AS component
|
|
, 'Cost by Volume' AS title
|
|
, 'Cost by Volume' AS title
|
|
, $height AS height
|
|
, $height AS height
|
|
, '$/'||$unit_volume AS ytitle
|
|
, '$/'||$unit_volume AS ytitle
|
|
-, $type AS type
|
|
|
|
|
|
+, CASE
|
|
|
|
+ WHEN (
|
|
|
|
+ SELECT count(DISTINCT product)
|
|
|
|
+ FROM sqlpage_txn
|
|
|
|
+ WHERE unit = $unit_volume
|
|
|
|
+ ) > $max_line_series::numeric
|
|
|
|
+ THEN 'scatter' ELSE $type
|
|
|
|
+ END AS type
|
|
, $log_scale::bool AS logarithmic
|
|
, $log_scale::bool AS logarithmic
|
|
, TRUE AS time
|
|
, TRUE AS time
|
|
, 0 AS ymin
|
|
, 0 AS ymin
|
|
@@ -48,7 +63,14 @@ SELECT 'chart' AS component
|
|
, 'Cost by Count' AS title
|
|
, 'Cost by Count' AS title
|
|
, $height AS height
|
|
, $height AS height
|
|
, '$/'||$unit_count_chart AS ytitle
|
|
, '$/'||$unit_count_chart AS ytitle
|
|
-, $type AS type
|
|
|
|
|
|
+, CASE
|
|
|
|
+ WHEN (
|
|
|
|
+ SELECT count(DISTINCT product)
|
|
|
|
+ FROM sqlpage_txn
|
|
|
|
+ WHERE unit = $unit_count_chart
|
|
|
|
+ ) > $max_line_series::numeric
|
|
|
|
+ THEN 'scatter' ELSE $type
|
|
|
|
+ END AS type
|
|
, $log_scale::bool AS logarithmic
|
|
, $log_scale::bool AS logarithmic
|
|
, TRUE AS time
|
|
, TRUE AS time
|
|
, 0 AS ymin
|
|
, 0 AS ymin
|