Skip to content

Commit e41b155

Browse files
author
Niilo Keinänen
committed
LCJS v8.0.0
1 parent e997545 commit e41b155

File tree

8 files changed

+21
-47
lines changed

8 files changed

+21
-47
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ Direct developer email support can be purchased through a [Support Plan][4] or b
7878
© LightningChart Ltd 2009-2022. All rights reserved.
7979

8080

81-
[XY cartesian chart]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/classes/ChartXY.html
82-
[Step options]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/enums/StepOptions.html
83-
[Individual point coloring]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/classes/IndividualPointFill.html
84-
[UI layout builders]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/variables/UILayoutBuilders.html
85-
[UI backgrounds]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/variables/UIBackgrounds.html
86-
[UI elements builders]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/variables/UIElementBuilders.html
87-
[UI button pictures]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/variables/UIButtonPictures.html
88-
[UI position origins]: https://lightningchart.com/js-charts/api-documentation/v7.1.0/variables/UIOrigins.html
81+
[XY cartesian chart]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/classes/ChartXY.html
82+
[Step options]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/enums/StepOptions.html
83+
[Individual point coloring]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/classes/IndividualPointFill.html
84+
[UI layout builders]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/variables/UILayoutBuilders.html
85+
[UI backgrounds]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/variables/UIBackgrounds.html
86+
[UI elements builders]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/variables/UIElementBuilders.html
87+
[UI button pictures]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/variables/UIButtonPictures.html
88+
[UI position origins]: https://lightningchart.com/js-charts/api-documentation/v8.0.0/variables/UIOrigins.html
8989
[Progressive random generator]: https://lightning-chart.github.io/xydata/classes/progressiverandomgenerator.html
9090

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"webpack-stream": "^7.0.0"
1818
},
1919
"dependencies": {
20-
"@lightningchart/lcjs": "^7.1.0",
21-
"@lightningchart/xydata": "^1.4.0"
20+
"@lightningchart/lcjs": "^8.0.0",
21+
"@lightningchart/xydata": "^1.5.0"
2222
},
2323
"lightningChart": {
2424
"eID": "0005"

src/index.js

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
const lcjs = require('@lightningchart/lcjs')
66

77
// Extract required parts from LightningChartJS.
8-
const { lightningChart, UILayoutBuilders, UIElementBuilders, emptyFill, UIOrigins, AxisTickStrategies, Themes } = lcjs
8+
const { lightningChart, UILayoutBuilders, UIElementBuilders, emptyFill, UIOrigins, AxisTickStrategies, LegendEntryClickBehaviors, Themes } = lcjs
99

1010
const chart = lightningChart({
1111
resourcesBaseUrl: new URL(document.head.baseURI).origin + new URL(document.head.baseURI).pathname + 'resources/',
1212
})
1313
.ChartXY({
14+
legend: {
15+
title: 'Step options',
16+
entries: {
17+
events: {
18+
click: LegendEntryClickBehaviors.focusClicked,
19+
}
20+
}
21+
},
1422
theme: Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined,
1523
})
1624
.setTitle('Survey Report')
@@ -19,7 +27,7 @@ const stepSeries = []
1927
const addSeries = (step) =>
2028
stepSeries.push(
2129
chart
22-
.addPointLineAreaSeries({ dataPattern: 'ProgressiveX', automaticColorIndex: 0 })
30+
.addPointLineSeries({ automaticColorIndex: 0 })
2331
.setName(step)
2432
.setVisible(false)
2533
.setCurvePreprocessing({ type: 'step', step })
@@ -91,7 +99,7 @@ let changedData = []
9199

92100
stepSeries.forEach((values, i) => {
93101
changedData = data.map((changex, index) => ({ x: index, y: changex.y }))
94-
values.add(changedData)
102+
values.appendJSON(changedData)
95103
})
96104

97105
changedData.forEach((_, index) => {
@@ -105,39 +113,5 @@ changedData.forEach((_, index) => {
105113
})
106114
chart.getDefaultAxisY().setTitle('Amount / Month').setInterval({ start: 0, end: 100, stopAxisAfter: false })
107115

108-
// Add UI controls for switching between step-mode-options.
109-
// NOTE: This is not the focus of the example, and will be better covered elsewhere.
110-
const stepControls = chart.addUIElement(UILayoutBuilders.Column)
111-
stepControls.addElement(UIElementBuilders.TextBox).setText('Step options')
112-
const buttonLayout = stepControls.addElement(UILayoutBuilders.Row)
113-
const radioButtons = []
114-
let switching = false
115-
const addRadioButton = (series) => {
116-
const checkBox = buttonLayout.addElement(UIElementBuilders.CheckBox).setButtonOnFillStyle(emptyFill).setButtonOffFillStyle(emptyFill)
117-
radioButtons.push(checkBox)
118-
series.attach(checkBox)
119-
checkBox.setOn(false)
120-
// Add radio button logic immediately afterwards so that it is applied after plot.
121-
// Attach logic (otherwise plot logic will override this)
122-
setTimeout(() => {
123-
checkBox.addEventListener('switch', (event) => {
124-
const state = event.state
125-
if (switching || !state) {
126-
return
127-
}
128-
// Deactivate other buttons
129-
for (const button of radioButtons) if (button !== checkBox) button.setOn(false)
130-
})
131-
}, 100)
132-
series.addEventListener('visiblechange', (e) => {
133-
checkBox.setPointerEvents(!e.isVisible)
134-
})
135-
}
136-
addRadioButton(stepSeries[0])
137-
addRadioButton(stepSeries[1])
138-
addRadioButton(stepSeries[2])
139-
const margin = 10
140-
stepControls.setPosition({ x: 30, y: 80 }).setOrigin(UIOrigins.CenterBottom).setMargin(margin)
141-
142116
// Apply initial selection
143117
stepSeries[1].setVisible(true)

stepPlot-cyberSpace.png

120 KB
Loading

stepPlot-darkGold.png

222 KB
Loading

stepPlot-light.png

4.54 KB
Loading

stepPlot-lightNature.png

15.4 KB
Loading

stepPlot-turquoiseHexagon.png

124 KB
Loading

0 commit comments

Comments
 (0)