Skip to content

Commit

Permalink
LCJS 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Snekw committed May 23, 2023
1 parent de28198 commit 361f966
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Direct developer email support can be purchased through a [Support Plan][4] or b
© LightningChart Ltd 2009-2022. All rights reserved.


[XY cartesian chart]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/classes/ChartXY.html
[Area point]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/interfaces/AreaPoint.html
[Area Range series]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/classes/AreaRangeSeries.html
[XY cartesian chart]: https://lightningchart.com/lightningchart-js-api-documentation/v4.1.0/classes/ChartXY.html
[Area point]: https://lightningchart.com/lightningchart-js-api-documentation/v4.1.0/interfaces/AreaPoint.html
[Area Range series]: https://lightningchart.com/lightningchart-js-api-documentation/v4.1.0/classes/AreaRangeSeries.html

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"webpack-stream": "^7.0.0"
},
"dependencies": {
"@arction/lcjs": "^4.0.1",
"@arction/lcjs": "^4.1.0",
"@arction/xydata": "^1.4.0"
},
"lightningChart": {
Expand Down
22 changes: 12 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ const lcjs = require('@arction/lcjs')
const { lightningChart, AxisTickStrategies, SolidFill, SolidLine, ColorRGBA, ColorHEX, LegendBoxBuilders, LinearGradientFill, Themes } =
lcjs

// Decide on an origin for DateTime axis.
const dateOrigin = new Date(2019, 3, 1)

// Create a XY Chart.
const chart = lightningChart().ChartXY({
// theme: Themes.darkGold
})
chart.getDefaultAxisX().setTickStrategy(AxisTickStrategies.DateTime, (tickStrategy) => tickStrategy.setDateOrigin(dateOrigin))
chart.setTitle('Daily temperature range, April 2019')
}).setTitle('Daily temperature range, April 2019')

const axisX = chart.getDefaultAxisX()
const axisY = chart.getDefaultAxisY().setTitle('Temperature (°C)').setScrollStrategy(undefined)

// Use DateTime TickStrategy and set the interval
axisX.setTickStrategy(AxisTickStrategies.DateTime)
.setInterval({
start: new Date(2019, 0, 1).getTime(),
end: new Date(2019, 0, 31).getTime()
})

// Daily temperature records
const recordRange = chart.addAreaRangeSeries()
// Current month daily temperature variations
Expand Down Expand Up @@ -83,7 +85,7 @@ const recordRangeData = []
// Current range
for (let i = 0; i < 31; i++) {
const randomPoint = () => {
const x = i
const x = new Date(2019, 0, i + 1).getTime()
let yMax
if (i > 0) {
const previousYMax = currentRangeData[i - 1].yMax
Expand Down Expand Up @@ -112,7 +114,7 @@ axisY.setInterval({ start: recordYMin - 5, end: recordYMax + 5, stopAxisAfter: f
// ----- Generate record temperatures
for (let i = 0; i < 31; i++) {
const randomPoint = () => {
const x = i
const x = new Date(2019, 0, i + 1).getTime()
const yMax = randomInt(recordYMax - 2, recordYMax + 2)
const yMin = randomInt(recordYMin - 1, recordYMin)
return {
Expand All @@ -125,11 +127,11 @@ for (let i = 0; i < 31; i++) {
}
// ----- Adding data points
recordRangeData.forEach((point, i) => {
recordRange.add({ position: point.x * 24 * 60 * 60 * 1000, high: point.yMax, low: point.yMin })
recordRange.add({ position: point.x, high: point.yMax, low: point.yMin })
})

currentRangeData.forEach((point, i) => {
currentRange.add({ position: point.x * 24 * 60 * 60 * 1000, high: point.yMax, low: point.yMin })
currentRange.add({ position: point.x, high: point.yMax, low: point.yMin })
})
// ----- Add legend box
const legendBox = chart
Expand Down

0 comments on commit 361f966

Please sign in to comment.