Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fordecyt_2019
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
fordecyt_2019
Commits
0d096323
Commit
0d096323
authored
Mar 20, 2021
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite series functions. Fix some legend columns
parent
05f293d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
50 deletions
+23
-50
centropais_periurbano_charts.js
public/js/centropais_periurbano_charts.js
+23
-50
No files found.
public/js/centropais_periurbano_charts.js
View file @
0d096323
...
@@ -24,50 +24,17 @@ const makeStackedBarSeries = (chart, name, category, value, color) => {
...
@@ -24,50 +24,17 @@ const makeStackedBarSeries = (chart, name, category, value, color) => {
series
.
stroke
=
am4core
.
color
(
color
);
series
.
stroke
=
am4core
.
color
(
color
);
}
}
const
makeStackedBarLineSeries
=
(
chart
,
name
,
category
,
value
,
barColor
,
yAxis
,
lineColor
)
=>
{
const
makeLineSeries
=
(
chart
,
name
,
value
,
percent
,
category
,
yAxis
,
color
)
=>
{
let
barSeries
=
chart
.
series
.
push
(
new
am4charts
.
ColumnSeries
());
barSeries
.
columns
.
template
.
width
=
am4core
.
percent
(
80
);
barSeries
.
name
=
name
;
barSeries
.
dataFields
.
categoryX
=
category
;
barSeries
.
dataFields
.
valueY
=
value
;
barSeries
.
columns
.
template
.
tooltipText
=
"{name}: {valueY.formatNumber('#,###.00')} Ha"
;
barSeries
.
dataItems
.
template
.
locations
.
categoryX
=
0.5
;
barSeries
.
stacked
=
true
;
barSeries
.
tooltip
.
pointerOrientation
=
"vertical"
;
barSeries
.
fill
=
am4core
.
color
(
barColor
);
barSeries
.
stroke
=
am4core
.
color
(
barColor
);
let
lineSeries
=
chart
.
series
.
push
(
new
am4charts
.
LineSeries
());
lineSeries
.
name
=
`%
${
name
}
`
;
lineSeries
.
dataFields
.
valueY
=
value
;
lineSeries
.
dataFields
.
categoryX
=
category
;
lineSeries
.
dataFields
.
valueYShow
=
"totalPercent"
;
// FIXME: using totalPercent chanhges values when turning series on or off
lineSeries
.
yAxis
=
yAxis
;
//stackedBarLineLineSeries.dataItems.template.locations.categoryX = 0.5;
lineSeries
.
stroke
=
am4core
.
color
(
lineColor
);
lineSeries
.
strokeWidth
=
3
;
lineSeries
.
propertyFields
.
strokeDasharray
=
"lineDash"
;
lineSeries
.
tooltip
.
label
.
textAlign
=
"middle"
;
lineSeries
.
stacked
=
true
;
lineSeries
.
calculatePercent
=
true
;
let
bullet
=
lineSeries
.
bullets
.
push
(
new
am4charts
.
Bullet
());
bullet
.
fill
=
am4core
.
color
(
lineColor
);
// tooltips grab fill from parent by default
bullet
.
tooltipText
=
"[#fff font-size: 15px]{name} en {categoryX}:
\n
[/][#fff font-size: 15px]{valueY.totalPercent.formatNumber('#.00')} %[/] [#fff][/]"
;
let
circle
=
bullet
.
createChild
(
am4core
.
Circle
);
circle
.
radius
=
4
;
circle
.
fill
=
am4core
.
color
(
"#fff"
);
circle
.
strokeWidth
=
3
;
}
const
makeLineSeries
=
(
chart
,
name
,
value
,
category
,
yAxis
,
color
)
=>
{
let
series
=
chart
.
series
.
push
(
new
am4charts
.
LineSeries
());
let
series
=
chart
.
series
.
push
(
new
am4charts
.
LineSeries
());
series
.
name
=
name
;
//"San Juan del río - Querétaro";
series
.
name
=
name
;
//"San Juan del río - Querétaro";
series
.
dataFields
.
valueY
=
value
;
series
.
dataFields
.
valueY
=
value
;
series
.
dataFields
.
categoryX
=
category
;
series
.
dataFields
.
categoryX
=
category
;
if
(
percent
)
{
series
.
dataFields
.
valueYShow
=
"totalPercent"
;
series
.
stacked
=
true
;
series
.
calculatePercent
=
true
;
}
// FIXME: using totalPercent chanhges values when turning series on or off
series
.
yAxis
=
yAxis
;
series
.
yAxis
=
yAxis
;
series
.
stroke
=
am4core
.
color
(
color
);
series
.
stroke
=
am4core
.
color
(
color
);
series
.
strokeWidth
=
3
;
series
.
strokeWidth
=
3
;
...
@@ -259,15 +226,20 @@ am4core.ready(function() {
...
@@ -259,15 +226,20 @@ am4core.ready(function() {
stackedBarLinePercentAxis
.
renderer
.
labels
.
template
.
fill
=
am4core
.
color
(
mainTextColor
);
stackedBarLinePercentAxis
.
renderer
.
labels
.
template
.
fill
=
am4core
.
color
(
mainTextColor
);
stackedBarLinePercentAxis
.
renderer
.
labels
.
template
.
fontSize
=
9
;
stackedBarLinePercentAxis
.
renderer
.
labels
.
template
.
fontSize
=
9
;
makeStackedBarLineSeries
(
stackedBarLineChart
,
"Bajo"
,
"category"
,
"value1"
,
"#f8caa0"
,
stackedBarLinePercentAxis
,
"#D197FA"
);
makeStackedBarSeries
(
stackedBarLineChart
,
"Bajo"
,
"category"
,
"value1"
,
"#f8caa0"
);
makeStackedBarLineSeries
(
stackedBarLineChart
,
"Medio"
,
"category"
,
"value2"
,
"#cf8a4f"
,
stackedBarLinePercentAxis
,
"#844DDF"
);
makeStackedBarSeries
(
stackedBarLineChart
,
"Medio"
,
"category"
,
"value2"
,
"#cf8a4f"
);
makeStackedBarLineSeries
(
stackedBarLineChart
,
"Alto"
,
"category"
,
"value3"
,
"#93592a"
,
stackedBarLinePercentAxis
,
"#351591"
);
makeStackedBarSeries
(
stackedBarLineChart
,
"Alto"
,
"category"
,
"value3"
,
"#93592a"
);
makeLineSeries
(
stackedBarLineChart
,
"% Bajo"
,
"value1"
,
true
,
"category"
,
stackedBarLinePercentAxis
,
"#D197FA"
);
makeLineSeries
(
stackedBarLineChart
,
"% Medio"
,
"value2"
,
true
,
"category"
,
stackedBarLinePercentAxis
,
"#844DDF"
);
makeLineSeries
(
stackedBarLineChart
,
"% Alto"
,
"value3"
,
true
,
"category"
,
stackedBarLinePercentAxis
,
"#351591"
);
// Use this to avoid turning on or off legend items.
// Use this to avoid turning on or off legend items.
// Remove if use of percentTotal is fixed in series
// Remove if use of percentTotal is fixed in series
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
clickable
=
false
;
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
clickable
=
false
;
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
focusable
=
false
;
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
focusable
=
false
;
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
cursorOverStyle
=
am4core
.
MouseCursorStyle
.
default
;
stackedBarLineChart
.
legend
.
itemContainers
.
template
.
cursorOverStyle
=
am4core
.
MouseCursorStyle
.
default
;
stackedBarLineChart
.
legend
.
maxColumns
=
3
;
//++++++++++++++++++++++++++++++++++++++++++++ HISTORICO POR TRAMOS ++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++ HISTORICO POR TRAMOS ++++++++++++++++++
...
@@ -356,24 +328,25 @@ am4core.ready(function() {
...
@@ -356,24 +328,25 @@ am4core.ready(function() {
let
lineChartValueAxis
=
lineChart
.
yAxes
.
push
(
new
am4charts
.
ValueAxis
());
let
lineChartValueAxis
=
lineChart
.
yAxes
.
push
(
new
am4charts
.
ValueAxis
());
lineChartValueAxis
.
min
=
0
;
lineChartValueAxis
.
min
=
0
;
//lineChartValueAxis.max = 100;
//lineChartValueAxis.max = 100;
lineChartValueAxis
.
strictMinMax
=
true
;
//
lineChartValueAxis.strictMinMax = true;
lineChartValueAxis
.
calculateTotals
=
true
;
lineChartValueAxis
.
calculateTotals
=
true
;
lineChartValueAxis
.
renderer
.
minWidth
=
50
;
lineChartValueAxis
.
renderer
.
minWidth
=
50
;
lineChartValueAxis
.
renderer
.
labels
.
template
.
fill
=
am4core
.
color
(
mainTextColor
);
lineChartValueAxis
.
renderer
.
labels
.
template
.
fill
=
am4core
.
color
(
mainTextColor
);
lineChartValueAxis
.
renderer
.
labels
.
template
.
fontSize
=
9
;
lineChartValueAxis
.
renderer
.
labels
.
template
.
fontSize
=
9
;
makeLineSeries
(
lineChart
,
"T7"
,
"Tramo7"
,
"category"
,
lineChartValueAxis
,
"#fddfb9"
);
makeLineSeries
(
lineChart
,
"T7"
,
"Tramo7"
,
false
,
"category"
,
lineChartValueAxis
,
"#fddfb9"
);
makeLineSeries
(
lineChart
,
"T8"
,
"Tramo8"
,
"category"
,
lineChartValueAxis
,
"#fb9a99"
);
makeLineSeries
(
lineChart
,
"T8"
,
"Tramo8"
,
false
,
"category"
,
lineChartValueAxis
,
"#fb9a99"
);
makeLineSeries
(
lineChart
,
"T9"
,
"Tramo9"
,
"category"
,
lineChartValueAxis
,
"#33a09b"
);
makeLineSeries
(
lineChart
,
"T9"
,
"Tramo9"
,
false
,
"category"
,
lineChartValueAxis
,
"#33a09b"
);
makeLineSeries
(
lineChart
,
"T10"
,
"Tramo10"
,
"category"
,
lineChartValueAxis
,
"#de6eb4"
);
makeLineSeries
(
lineChart
,
"T10"
,
"Tramo10"
,
false
,
"category"
,
lineChartValueAxis
,
"#de6eb4"
);
makeLineSeries
(
lineChart
,
"T11"
,
"Tramo11"
,
"category"
,
lineChartValueAxis
,
"#4db0ec"
);
makeLineSeries
(
lineChart
,
"T11"
,
"Tramo11"
,
false
,
"category"
,
lineChartValueAxis
,
"#4db0ec"
);
makeLineSeries
(
lineChart
,
"T12"
,
"Tramo12"
,
"category"
,
lineChartValueAxis
,
"#2be829"
);
makeLineSeries
(
lineChart
,
"T12"
,
"Tramo12"
,
false
,
"category"
,
lineChartValueAxis
,
"#2be829"
);
// Use this to avoid turning on or off legend items.
// Use this to avoid turning on or off legend items.
// Remove if use of percentTotal is fixed in series
// Remove if use of percentTotal is fixed in series
lineChart
.
legend
.
itemContainers
.
template
.
clickable
=
false
;
lineChart
.
legend
.
itemContainers
.
template
.
clickable
=
false
;
lineChart
.
legend
.
itemContainers
.
template
.
focusable
=
false
;
lineChart
.
legend
.
itemContainers
.
template
.
focusable
=
false
;
lineChart
.
legend
.
itemContainers
.
template
.
cursorOverStyle
=
am4core
.
MouseCursorStyle
.
default
;
lineChart
.
legend
.
itemContainers
.
template
.
cursorOverStyle
=
am4core
.
MouseCursorStyle
.
default
;
lineChart
.
legend
.
maxColumns
=
3
;
// Create bar + percentage chart
// Create bar + percentage chart
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment