Skip to content

Commit

Permalink
Merge pull request #54 from ACE-IoT-Solutions/nic/dev
Browse files Browse the repository at this point in the history
Fix builtin Example
  • Loading branch information
nicfv authored Apr 14, 2024
2 parents 034049a + 19da7f9 commit 695b35c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 232 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.

## 0.1.2

- Fix the builtin example
- Update dependency versions
- Update commands in reamde from `yarn` to `npm`
- Remove provisioning folder
Expand Down
218 changes: 2 additions & 216 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/ACESVGjsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ export class ACESVGPanel extends PureComponent<Props, PanelState> {
}

initializeMappings(svgNode: SVGElement | SVGDom) {
const svgMappings = this.props.options.svgMappings;
let currentElements: MappedElements = { ...this.state.mappedElements };
currentElements = {}; // why does it immediately get set to {}?
const svgMappings = this.props.options.svgMappings,
currentElements: MappedElements = {};
for (let i = 0; i < svgMappings.length; i++) {
if (svgMappings[i].mappedName !== '') {
currentElements[this.props.options.svgMappings[i].mappedName] = svgNode.findOne(
Expand Down Expand Up @@ -221,7 +220,7 @@ export class ACESVGPanel extends PureComponent<Props, PanelState> {
}
} catch (e) {
this.setState({ initialized: true });
console.log(`User init code failed: ${e}`);
console.error('User init code failed:', e);
}
}

Expand Down Expand Up @@ -249,7 +248,7 @@ export class ACESVGPanel extends PureComponent<Props, PanelState> {
);
}
} catch (e) {
console.log(`User event code failed: ${e}`);
console.error('User event code failed:', e);
}

return this.state.svgNode ? this.state.svgNode.svg() : null;
Expand Down
20 changes: 9 additions & 11 deletions src/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,11 @@ export const props_defaults: ACESVGDefaults = {
>
`,
initSource: `options.animateLogo = (svgmap, data) => {
let buffer = data.series[0].fields[1].values.buffer;
let valueCount = buffer.length
let values = data.series[0].fields[1].values;
let valueCount = values.length
let chartData = [];
for (let i=0; i<valueCount; i+=(Math.floor(valueCount / 4)-1)) {
chartData.push(buffer[i])
chartData.push(values[i])
}
let minData = chartData.reduce((acc, val) => {
return Math.min(acc, val);
Expand All @@ -765,15 +765,14 @@ export const props_defaults: ACESVGDefaults = {
[svgmap.barOne, svgmap.barTwo, svgmap.barThree, svgmap.barFour].forEach((elem) => {
elem.animate(1000).ease('<>').move(elem.x(), ((iconHeight * (chartData[0] / maxData)) - elem.height())).loop(0, true);
});
}
`,
}`,
eventSource: `// example of calling a function defined in the init script
options.animateLogo(svgmap, data);
// Here we're going to initialized some variables just to make things less verbose
// This is the raw buffer from the values field of the DataFrame
let buffer = data.series[0].fields[1].values.buffer;
// This is the raw data buffer from the values field of the DataFrame
let values = data.series[0].fields[1].values;
// here we collect the most recent value from the Data Frame
let lastValue = buffer[buffer.length -1]
let lastValue = values[values.length - 1];
// We need to collect the center of the fan as a static value here, otherwise it will cause a feedback loop in the animation.
// The rotate animation will use the center of the bounding box by default, but of irregular shaped items, like these fan blades
// the center is not the center axis of rotation
Expand All @@ -799,13 +798,12 @@ svgmap.fanBlades.animateOn(1000, (lastValue > 40), (elem) => {
svgmap.lampLens.showOn(lastValue>10);
svgmap.lampRays.showOn(lastValue>10);
// Here we hide the water drop when leakCond is false
svgmap.waterDrop.showOn(leakCond)
svgmap.waterDrop.showOn(leakCond);
// and here we animate the water drop when leakCond is true
svgmap.waterDrop.animateOn(2000 - lastValue *20, leakCond, (elem) => {
// we're using single direction easing to give a gravity affect, and scaling the drop down as it falls off the screen
elem.ease('<').transform({translateY: 1000, scale: 0.00001}).loop();
})
`,
});`,
svgMappings: [
{
mappedName: 'barTwo',
Expand Down

0 comments on commit 695b35c

Please sign in to comment.