Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
T
Telegram chart contest
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vasily Belolapotkov
Telegram chart contest
Commits
826ccb62
Commit
826ccb62
authored
Mar 23, 2019
by
Vasily Belolapotkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: reorganize types and components
parent
e6b76d1e
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
238 additions
and
216 deletions
+238
-216
src/app/charts.ts
src/app/charts.ts
+43
-0
src/app/index.ts
src/app/index.ts
+24
-0
src/app/theme-switcher.ts
src/app/theme-switcher.ts
+7
-4
src/chart-components/chart-preview.ts
src/chart-components/chart-preview.ts
+2
-2
src/chart-components/chart-state.ts
src/chart-components/chart-state.ts
+10
-82
src/chart-components/chart.ts
src/chart-components/chart.ts
+4
-8
src/chart-components/check-icon.ts
src/chart-components/check-icon.ts
+1
-1
src/chart-components/legend.ts
src/chart-components/legend.ts
+2
-3
src/chart-components/plot-area.ts
src/chart-components/plot-area.ts
+3
-3
src/chart-components/plot.ts
src/chart-components/plot.ts
+12
-27
src/chart-components/plots-inspector.ts
src/chart-components/plots-inspector.ts
+11
-8
src/chart-components/transparent-image.ts
src/chart-components/transparent-image.ts
+0
-0
src/chart-components/types.ts
src/chart-components/types.ts
+98
-0
src/chart-components/x-axis.ts
src/chart-components/x-axis.ts
+10
-5
src/chart-components/y-axis.ts
src/chart-components/y-axis.ts
+8
-5
src/chart/chart-component.ts
src/chart/chart-component.ts
+0
-11
src/chart/chart-utils.ts
src/chart/chart-utils.ts
+0
-0
src/index.ts
src/index.ts
+3
-57
src/utils/ui.ts
src/utils/ui.ts
+0
-0
No files found.
src/app/charts.ts
0 → 100644
View file @
826ccb62
import
{
makeChart
}
from
'
../chart-components/chart
'
;
import
{
ISrcData
,
SrcTypes
}
from
'
../data/srcData
'
;
import
{
ChartType
,
IChartData
}
from
'
../chart-components/types
'
;
export
function
renderCharts
(
chartsData
:
any
[],
containerElement
:
HTMLElement
,
):
void
{
chartsData
.
forEach
(
rawChartData
=>
{
const
formattedChartData
=
makeChartData
(
rawChartData
);
const
chart
=
makeChart
(
formattedChartData
);
chart
.
render
(
containerElement
);
});
}
function
makeChartData
(
rawCharData
:
ISrcData
):
IChartData
{
const
chartData
:
IChartData
=
{
xAxis
:
[],
dataSets
:
[],
};
const
{
columns
,
types
,
names
,
colors
}
=
rawCharData
;
columns
.
forEach
((
column
,
index
)
=>
{
const
name
=
<
string
>
column
[
0
];
const
values
=
<
number
[]
>
column
.
slice
(
1
);
if
(
types
[
name
]
===
SrcTypes
.
x
)
{
chartData
.
xAxis
=
values
;
return
;
}
chartData
.
dataSets
.
push
({
values
,
id
:
index
,
name
:
names
[
name
],
type
:
ChartType
.
line
,
color
:
colors
[
name
],
isVisible
:
true
,
});
});
return
chartData
;
}
src/app/index.ts
0 → 100644
View file @
826ccb62
import
{
ISrcData
}
from
'
../data/srcData
'
;
import
{
makeHtmlElement
}
from
'
../utils/ui
'
;
import
{
renderThemeSwitcher
}
from
'
./theme-switcher
'
;
import
{
renderCharts
}
from
'
./charts
'
;
export
function
renderApp
(
chartsData
:
ISrcData
[]):
void
{
const
rootElement
=
renderRootElement
();
renderThemeSwitcher
(
rootElement
);
renderCharts
(
chartsData
,
rootElement
);
}
function
renderRootElement
():
HTMLElement
{
const
rootElement
=
createRootElement
();
document
.
body
.
appendChild
(
rootElement
);
return
rootElement
;
}
function
createRootElement
():
HTMLElement
{
const
rootElement
=
makeHtmlElement
(
'
div
'
,
{
attributes
:
{
id
:
'
root
'
},
});
rootElement
.
innerHTML
=
'
<h1>Followers</h1>
'
;
return
rootElement
;
}
src/theme-switcher.ts
→
src/
app/
theme-switcher.ts
View file @
826ccb62
import
{
makeHtmlElement
}
from
'
./chart/ui-utils
'
;
import
{
DOMContainerElement
,
IRenderable
}
from
'
./chart/chart-component
'
;
import
{
makeHtmlElement
}
from
'
../utils/ui
'
;
interface
IThemeSwitcher
{
readonly
render
:
(
container
:
HTMLElement
)
=>
void
;
}
export
function
renderThemeSwitcher
(
container
:
HTMLElement
):
void
{
const
switcher
=
makeThemeSwitcher
();
switcher
.
render
(
container
);
}
function
makeThemeSwitcher
():
I
Renderable
<
null
>
{
function
makeThemeSwitcher
():
I
ThemeSwitcher
{
let
currentTheme
=
'
light
'
;
let
control
:
HTMLElement
;
...
...
@@ -14,7 +17,7 @@ function makeThemeSwitcher(): IRenderable<null> {
render
,
});
function
render
(
container
:
DOMContainer
Element
)
{
function
render
(
container
:
HTML
Element
)
{
const
switcher
=
makeHtmlElement
(
'
div
'
,
{
classList
:
[
'
theme-switcher
'
],
});
...
...
src/chart/chart-preview.ts
→
src/chart
-components
/chart-preview.ts
View file @
826ccb62
import
{
applyElementConfig
,
makeHtmlElement
,
toPx
}
from
'
.
/ui-utils
'
;
import
{
ChartComponentFactory
}
from
'
./
chart-component
'
;
import
{
applyElementConfig
,
makeHtmlElement
,
toPx
}
from
'
.
./utils/ui
'
;
import
{
ChartComponentFactory
}
from
'
./
types
'
;
import
{
renderPlots
}
from
'
./plot
'
;
import
{
makeTransparentImage
}
from
'
./transparent-image
'
;
...
...
src/chart/chart-state.ts
→
src/chart
-components
/chart-state.ts
View file @
826ccb62
export
type
Timestamp
=
number
;
export
enum
ChartType
{
line
=
'
line
'
,
}
export
interface
IChartData
{
xAxis
:
Timestamp
[];
dataSets
?:
IDataSet
[];
}
export
interface
IDataSet
{
id
:
number
;
type
:
ChartType
;
name
:
string
;
color
?:
string
;
values
:
number
[];
isVisible
:
boolean
;
}
export
interface
IRange
{
start
:
number
;
end
:
number
;
distance
:
number
;
}
export
interface
IChartState
{
readonly
xAxis
:
Timestamp
[];
readonly
dataSets
:
IDataSet
[];
readonly
xTotalRange
:
IRange
;
readonly
yTotalRange
:
IRange
;
xScale
:
number
;
xOffset
:
number
;
yScale
:
number
;
yOffset
:
number
;
yLabels
:
number
[];
inspectorIsActive
:
boolean
;
inspectorValues
:
IInspectorValues
;
setXViewRange
:
(
xScale
:
number
,
xOffset
:
number
)
=>
void
;
toggleDataSetVisibility
:
(
dataSet
:
IDataSet
)
=>
void
;
setInspectorVisibility
:
(
isActive
:
boolean
)
=>
void
;
moveInspector
:
(
relativeXOffset
:
number
)
=>
void
;
}
export
interface
IInspectorValues
{
xValue
:
Timestamp
;
yValues
:
IInspectorValue
[];
}
export
interface
IInspectorValue
{
name
:
string
;
color
:
string
;
value
:
number
;
isVisible
:
boolean
;
}
import
{
IChartData
,
IChartState
,
IChartStateController
,
IDataSet
,
IInspectorValue
,
IInspectorValues
,
IRange
,
Timestamp
,
}
from
'
./types
'
;
export
function
makeChartState
(
chartData
:
IChartData
):
IChartState
{
const
yLabelsCount
=
6
;
...
...
@@ -223,18 +179,6 @@ export function makeChartState(chartData: IChartData): IChartState {
export
type
ChartEventListener
=
(
chartState
:
IChartState
)
=>
void
;
export
interface
IChartStateController
{
getState
:
()
=>
IChartState
;
changeXViewRange
:
(
xScale
:
number
,
xOffset
?:
number
)
=>
void
;
toggleDataSetVisibility
:
(
dataSet
:
IDataSet
)
=>
void
;
addListener
:
(
eventName
:
string
,
listener
:
ChartEventListener
)
=>
void
;
removeListener
:
(
eventName
:
string
,
listener
:
ChartEventListener
)
=>
void
;
showInspector
:
()
=>
void
;
hideInspector
:
()
=>
void
;
toggleInspector
:
()
=>
void
;
moveInspector
:
(
xOffset
:
number
)
=>
void
;
}
export
function
makeChartStateController
(
chartState
:
IChartState
,
):
IChartStateController
{
...
...
@@ -246,7 +190,6 @@ export function makeChartStateController(
changeXViewRange
,
toggleDataSetVisibility
,
addListener
,
removeListener
,
showInspector
,
hideInspector
,
toggleInspector
,
...
...
@@ -263,21 +206,6 @@ export function makeChartStateController(
listeners
.
set
(
eventName
,
eventListeners
);
}
function
removeListener
(
eventName
:
string
,
listener
:
ChartEventListener
)
{
const
eventListeners
=
listeners
.
get
(
eventName
)
||
[];
const
index
=
eventListeners
.
indexOf
(
listener
);
if
(
index
<
0
)
{
return
;
}
const
updatedEventListeners
=
[
...
eventListeners
.
slice
(
0
,
index
),
...
eventListeners
.
slice
(
index
+
1
),
];
listeners
.
set
(
eventName
,
updatedEventListeners
);
}
function
fireEvent
(
eventName
:
string
)
{
const
eventListeners
=
listeners
.
get
(
eventName
)
||
[];
eventListeners
.
forEach
(
listener
=>
listener
(
state
));
...
...
src/chart
/index
.ts
→
src/chart
-components/chart
.ts
View file @
826ccb62
import
{
makeHtmlElement
}
from
'
.
/ui-utils
'
;
import
{
makeHtmlElement
}
from
'
.
./utils/ui
'
;
import
{
makeChartPreview
}
from
'
./chart-preview
'
;
import
{
IChartData
,
makeChartState
,
makeChartStateController
,
}
from
'
./chart-state
'
;
import
{
makeChartState
,
makeChartStateController
}
from
'
./chart-state
'
;
import
{
I
Renderable
}
from
'
./chart-component
'
;
import
{
I
ChartData
,
IChartComponent
}
from
'
./types
'
;
import
{
makePlotArea
}
from
'
./plot-area
'
;
import
{
makeLegend
}
from
'
./legend
'
;
export
function
makeChart
(
chartData
:
IChartData
):
I
Renderable
<
any
>
{
export
function
makeChart
(
chartData
:
IChartData
):
I
ChartComponent
<
any
>
{
const
chartState
=
makeChartState
(
chartData
);
const
chartStateController
=
makeChartStateController
(
chartState
);
...
...
src/chart/check-icon.ts
→
src/chart
-components
/check-icon.ts
View file @
826ccb62
import
checkSolidSvg
from
'
../assets/check-solid.svg
'
;
import
{
makeHtmlElement
}
from
'
.
/ui-utils
'
;
import
{
makeHtmlElement
}
from
'
.
./utils/ui
'
;
export
function
makeCheckIcon
():
HTMLElement
{
const
el
=
makeHtmlElement
(
'
i
'
,
{
...
...
src/chart/legend.ts
→
src/chart
-components
/legend.ts
View file @
826ccb62
import
{
ChartComponentFactory
,
DOMContainerElement
}
from
'
./chart-component
'
;
import
{
applyElementConfig
,
makeHtmlElement
}
from
'
./ui-utils
'
;
import
{
IDataSet
}
from
'
./chart-state
'
;
import
{
DOMContainerElement
,
ChartComponentFactory
,
IDataSet
}
from
'
./types
'
;
import
{
applyElementConfig
,
makeHtmlElement
}
from
'
../utils/ui
'
;
import
{
makeCheckIcon
}
from
'
./check-icon
'
;
export
const
makeLegend
:
ChartComponentFactory
<
null
>
=
function
(
...
...
src/chart/plot-area.ts
→
src/chart
-components
/plot-area.ts
View file @
826ccb62
import
{
ChartComponentFactory
,
DOMContainerElement
}
from
'
./chart-component
'
;
import
{
ISize
,
renderPlots
}
from
'
./plot
'
;
import
{
makeHtmlElement
}
from
'
.
/ui-utils
'
;
import
{
DOMContainerElement
,
ChartComponentFactory
,
ISize
}
from
'
./types
'
;
import
{
renderPlots
}
from
'
./plot
'
;
import
{
makeHtmlElement
}
from
'
.
./utils/ui
'
;
interface
IPlotAreaProps
{
plotWidth
:
number
;
...
...
src/chart/plot.ts
→
src/chart
-components
/plot.ts
View file @
826ccb62
import
{
IAttributesMap
,
applyElementConfig
,
IAttributesMap
,
makeLinearAnimation
,
makeSvgElement
,
makeSvgRootElement
,
makeLinearAnimation
,
}
from
'
./ui-utils
'
;
import
{
DOMContainerElement
,
IRenderable
}
from
'
./chart-component
'
;
}
from
'
../utils/ui
'
;
import
{
IChartStateController
,
DOMContainerElement
,
IAxesConfig
,
IChartComponent
,
ICoordinates
,
IDataSet
,
IRange
,
ISize
,
IZoomConfig
,
Timestamp
,
}
from
'
./
chart-state
'
;
}
from
'
./
types
'
;
import
{
makeYAxis
}
from
'
./y-axis
'
;
import
{
makeXAxis
}
from
'
./x-axis
'
;
import
{
makePlotsInspector
}
from
'
./plots-inspector
'
;
...
...
@@ -23,7 +28,7 @@ interface IPlotContainerAttributes extends IAttributesMap {
viewBox
:
string
;
}
interface
IPlots
extends
I
Renderable
<
IPlotsProps
>
{
interface
IPlots
extends
I
ChartComponent
<
IPlotsProps
>
{
renderDataSets
:
(
xAxis
:
Timestamp
[],
dataSets
:
IDataSet
[])
=>
void
;
}
...
...
@@ -32,7 +37,7 @@ interface IPlotsProps {
zoomConfig
:
IZoomConfig
;
}
export
interface
IPlotContainer
extends
I
Renderable
<
ISize
>
{
export
interface
IPlotContainer
extends
I
ChartComponent
<
ISize
>
{
renderPlots
:
()
=>
void
;
renderAxes
:
()
=>
void
;
renderInspector
:
()
=>
void
;
...
...
@@ -45,26 +50,6 @@ export interface IPlotsConfig {
enableInspector
?:
boolean
;
}
export
interface
ISize
{
width
:
number
;
height
:
number
;
}
interface
IZoomConfig
{
x
:
boolean
;
y
:
boolean
;
}
export
interface
IAxesConfig
{
x
:
boolean
;
y
:
boolean
;
}
export
interface
ICoordinates
{
x
:
number
;
y
:
number
;
}
export
function
renderPlots
(
htmlContainer
:
HTMLElement
,
chartStateController
:
IChartStateController
,
...
...
src/chart/plots-inspector.ts
→
src/chart
-components
/plots-inspector.ts
View file @
826ccb62
import
{
IChartStateController
,
IInspectorValue
}
from
'
./chart-state
'
;
import
{
DOMContainerElement
,
IRenderable
}
from
'
./chart-component
'
;
import
{
ISize
}
from
'
./plot
'
;
import
{
DOMContainerElement
,
ISize
,
IInspectorValue
,
ChartComponentFactory
,
}
from
'
./types
'
;
import
{
applyElementConfig
,
IAttributesMap
,
makeHtmlElement
,
makeSvgElement
,
}
from
'
.
/ui-utils
'
;
}
from
'
.
./utils/ui
'
;
interface
IPlotsInspectorProps
{
plotSize
:
ISize
;
tooltipContainer
:
HTMLElement
;
}
export
function
makePlotsInspector
(
chartStateController
:
IChartStateController
,
):
IRenderable
<
IPlotsInspectorProps
>
{
export
const
makePlotsInspector
:
ChartComponentFactory
<
IPlotsInspectorProps
>
=
function
(
chartStateController
)
{
const
stateController
=
chartStateController
;
const
svgPointRadius
=
'
5
'
;
...
...
@@ -249,4 +252,4 @@ export function makePlotsInspector(
)
.
join
(
''
)}
</div> `
;
}
}
}
;
src/chart/transparent-image.ts
→
src/chart
-components
/transparent-image.ts
View file @
826ccb62
File moved
src/chart-components/types.ts
0 → 100644
View file @
826ccb62
import
{
ChartEventListener
}
from
'
./chart-state
'
;
export
type
Timestamp
=
number
;
export
enum
ChartType
{
line
=
'
line
'
,
}
export
interface
IChartData
{
xAxis
:
Timestamp
[];
dataSets
?:
IDataSet
[];
}
export
interface
IDataSet
{
id
:
number
;
type
:
ChartType
;
name
:
string
;
color
?:
string
;
values
:
number
[];
isVisible
:
boolean
;
}
export
interface
IRange
{
start
:
number
;
end
:
number
;
distance
:
number
;
}
export
interface
IInspectorValues
{
xValue
:
Timestamp
;
yValues
:
IInspectorValue
[];
}
export
interface
IInspectorValue
{
name
:
string
;
color
:
string
;
value
:
number
;
isVisible
:
boolean
;
}
export
interface
ISize
{
width
:
number
;
height
:
number
;
}
export
interface
IZoomConfig
{
x
:
boolean
;
y
:
boolean
;
}
export
interface
IAxesConfig
{
x
:
boolean
;
y
:
boolean
;
}
export
interface
ICoordinates
{
x
:
number
;
y
:
number
;
}
export
interface
IChartState
{
readonly
xAxis
:
Timestamp
[];
readonly
dataSets
:
IDataSet
[];
readonly
xTotalRange
:
IRange
;
readonly
yTotalRange
:
IRange
;
xScale
:
number
;
xOffset
:
number
;
yScale
:
number
;
yOffset
:
number
;
yLabels
:
number
[];
inspectorIsActive
:
boolean
;
inspectorValues
:
IInspectorValues
;
setXViewRange
:
(
xScale
:
number
,
xOffset
:
number
)
=>
void
;
toggleDataSetVisibility
:
(
dataSet
:
IDataSet
)
=>
void
;
setInspectorVisibility
:
(
isActive
:
boolean
)
=>
void
;
moveInspector
:
(
relativeXOffset
:
number
)
=>
void
;
}
export
interface
IChartStateController
{
getState
:
()
=>
IChartState
;
changeXViewRange
:
(
xScale
:
number
,
xOffset
?:
number
)
=>
void
;
toggleDataSetVisibility
:
(
dataSet
:
IDataSet
)
=>
void
;
addListener
:
(
eventName
:
string
,
listener
:
ChartEventListener
)
=>
void
;
showInspector
:
()
=>
void
;
hideInspector
:
()
=>
void
;
toggleInspector
:
()
=>
void
;
moveInspector
:
(
xOffset
:
number
)
=>
void
;
}
export
type
ChartComponentFactory
<
TProps
>
=
(
stateController
:
IChartStateController
,
)
=>
IChartComponent
<
TProps
>
;
export
type
DOMContainerElement
=
HTMLElement
|
SVGElement
;
export
interface
IChartComponent
<
TProps
>
{
render
:
(
container
:
DOMContainerElement
,
props
?:
TProps
)
=>
void
;
}
src/chart/x-axis.ts
→
src/chart
-components
/x-axis.ts
View file @
826ccb62
import
{
IChartStateController
,
Timestamp
}
from
'
./chart-state
'
;
import
{
DOMContainerElement
,
IRenderable
}
from
'
./chart-component
'
;
import
{
ISize
}
from
'
./plot
'
;
import
{
DOMContainerElement
,
IChartStateController
,
ISize
,
IChartComponent
,
Timestamp
,
}
from
'
./types
'
;
import
{
applyElementConfig
,
makeSvgElement
,
makeSvgRootElement
,
}
from
'
.
/ui-utils
'
;
}
from
'
.
./utils/ui
'
;
interface
IXAxisProps
{
plotSize
:
ISize
;
...
...
@@ -14,7 +19,7 @@ interface IXAxisProps {
export
function
makeXAxis
(
chartStateController
:
IChartStateController
,
):
I
Renderable
<
IXAxisProps
>
{
):
I
ChartComponent
<
IXAxisProps
>
{
const
stateController
=
chartStateController
;
const
dayRange
=
24
*
60
*
60
*
1000
;
const
xTextLabelOffset
=
25
;
...
...
src/chart/y-axis.ts
→
src/chart
-components
/y-axis.ts
View file @
826ccb62
import
{
IChartStateController
}
from
'
./chart-state
'
;
import
{
DOMContainerElement
,
IRenderable
}
from
'
./chart-component
'
;
import
{
IChartComponent
,
IChartStateController
,
DOMContainerElement
,
ISize
,
}
from
'
./types
'
;
import
{
applyElementConfig
,
formatNumber
,
makeLinearAnimation
,
makeSvgElement
,
}
from
'
./ui-utils
'
;
import
{
ISize
}
from
'
./plot
'
;
}
from
'
../utils/ui
'
;
interface
IYAxisProps
{
plotSize
:
ISize
;
...
...
@@ -14,7 +17,7 @@ interface IYAxisProps {
export
function
makeYAxis
(
chartStateController
:
IChartStateController
,
):
I
Renderable
<
IYAxisProps
>
{
):
I
ChartComponent
<
IYAxisProps
>
{
const
stateController
=
chartStateController
;
let
svgAxis
:
SVGElement
;
...
...
src/chart/chart-component.ts
deleted
100644 → 0
View file @
e6b76d1e
import
{
IChartStateController
}
from
'
./chart-state
'
;
export
type
DOMContainerElement
=
HTMLElement
|
SVGElement
;
export
interface
IRenderable
<
TProps
>
{
render
:
(
container
:
DOMContainerElement
,
props
?:
TProps
)
=>
void
;
}
export
type
ChartComponentFactory
<
TProps
>
=
(
stateController
:
IChartStateController
,
)
=>
IRenderable
<
TProps
>
;
src/chart/chart-utils.ts
deleted
100644 → 0
View file @
e6b76d1e
src/index.ts
View file @
826ccb62
import
'
./styles/index.scss
'
;
import
{
renderApp
}
from
'
./app
'
;
import
chartsData
from
'
./data/chart_data.json
'
;
import
{
makeChart
}
from
'
./chart
'
;
import
{
IChartData
,
ChartType
}
from
'
./chart/chart-state
'
;
import
{
ISrcData
,
SrcTypes
}
from
'
./data/srcData
'
;
import
{
renderThemeSwitcher
}
from
'
./theme-switcher
'
;
renderApp
();
function
renderApp
():
void
{
const
rootElement
=
createRootElement
();
document
.
body
.
appendChild
(
rootElement
);
renderThemeSwitcher
(
rootElement
);
renderCharts
(
chartsData
,
rootElement
);
}
function
createRootElement
():
HTMLElement
{
const
rootElement
=
document
.
createElement
(
'
div
'
);
rootElement
.
id
=
'
root
'
;
rootElement
.
innerHTML
=
'
<h1>Followers</h1>
'
;
return
rootElement
;
}
function
renderCharts
(
chartsData
:
any
[],
containerElement
:
HTMLElement
):
void
{
chartsData
.
forEach
(
rawChartData
=>
{
const
formattedChartData
=
makeChartData
(
rawChartData
);
const
chart
=
makeChart
(
formattedChartData
);
chart
.
render
(
containerElement
);
});
}
function
makeChartData
(
rawCharData
:
ISrcData
):
IChartData
{
const
chartData
:
IChartData
=
{
xAxis
:
[],
dataSets
:
[],
};
const
{
columns
,
types
,
names
,
colors
}
=
rawCharData
;
columns
.
forEach
((
column
,
index
)
=>
{
const
name
=
<
string
>
column
[
0
];