parent
3a2effdf99
commit
1ccd8b1c16
1 changed files with 6 additions and 9 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
import karax / [kbase, vdom, kdom, vstyles, karax, karaxdsl, jdict, jstrutils, jjson]
|
import karax / [kbase, vdom, kdom, vstyles, karax, karaxdsl, jdict, jstrutils, jjson]
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -9,18 +7,13 @@ type
|
||||||
var
|
var
|
||||||
currentView = Customers
|
currentView = Customers
|
||||||
|
|
||||||
setOnHashChange(proc(hash: cstring) =
|
|
||||||
if hash == cstring"#/Products": currentView = Products
|
|
||||||
else: currentView = Customers
|
|
||||||
)
|
|
||||||
|
|
||||||
type
|
type
|
||||||
EChart* = ref object
|
EChart* = ref object
|
||||||
|
|
||||||
proc echartsInit(n: Element): EChart {.importc: "echarts.init".}
|
proc echartsInit(n: Element): EChart {.importc: "echarts.init".}
|
||||||
proc setOption(x: EChart; option: JsonNode) {.importcpp.}
|
proc setOption(x: EChart; option: JsonNode) {.importcpp.}
|
||||||
|
|
||||||
proc postRender() =
|
proc postRender(data: RouterData) =
|
||||||
if currentView == Products:
|
if currentView == Products:
|
||||||
let myChart = echartsInit(kdom.getElementById("echartSection"))
|
let myChart = echartsInit(kdom.getElementById("echartSection"))
|
||||||
# specify chart configuration item and data
|
# specify chart configuration item and data
|
||||||
|
|
@ -44,7 +37,11 @@ proc postRender() =
|
||||||
}
|
}
|
||||||
myChart.setOption(option)
|
myChart.setOption(option)
|
||||||
|
|
||||||
proc createDom(): VNode =
|
proc createDom(data: RouterData): VNode =
|
||||||
|
let hash = data.hashPart
|
||||||
|
if hash == cstring"#/Products": currentView = Products
|
||||||
|
else: currentView = Customers
|
||||||
|
|
||||||
result = buildHtml(tdiv):
|
result = buildHtml(tdiv):
|
||||||
ul(class = "tabs"):
|
ul(class = "tabs"):
|
||||||
for v in low(Views)..high(Views):
|
for v in low(Views)..high(Views):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue