Skip to content

Commit

Permalink
feat(examples): simple tooltip example (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhannes committed Nov 16, 2019
1 parent 1134ae9 commit e4b4b5f
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"jest-pnp-resolver": "1.2.1",
"jest-resolve": "24.7.1",
"mini-css-extract-plugin": "0.6.0",
"monaco-editor": "0.16.2",
"monaco-editor": "0.18.1",
"monaco-editor-webpack-plugin": "1.7.0",
"optimize-css-assets-webpack-plugin": "5.0.1",
"picasso-plugin-hammer": "0.27.0",
Expand All @@ -50,7 +50,7 @@
"react-app-polyfill": "1.0.4",
"react-dev-utils": "9.1.0",
"react-dom": "16.8.6",
"react-monaco-editor": "0.25.1",
"react-monaco-editor": "0.32.1",
"resolve": "1.12.0",
"run-script": "0.1.1",
"sass-loader": "7.1.0",
Expand Down
129 changes: 129 additions & 0 deletions src/examples/simple-tooltip-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const code = `
return {
interactions: [{
type: 'native',
events: {
mousemove(e) {
const tooltip = this.chart.component('tooltip');
tooltip.emit('show', e);
},
mouseleave(e) {
const tooltip = this.chart.component('tooltip');
tooltip.emit('hide');
}
}
}],
scales: {
s: {
data: {
field: 'Sales'
},
expand: 0.2,
invert: true
},
m: {
data: {
field: 'Margin'
},
expand: 0.2
},
col: {
data: { extract: { field: 'Year' } },
type: 'color'
}
},
components: [{
key: 'y-axis',
type: 'axis',
scale: 's',
dock: 'left'
}, {
type: 'legend-cat',
dock: 'right',
scale: 'col'
}, {
key: 'x-axis',
type: 'axis',
scale: 'm',
dock: 'bottom'
}, {
key: 'p',
type: 'point',
data: {
extract: {
field: 'Month',
props: {
y: { field: 'Sales' },
x: { field: 'Margin' },
group: { field: 'Year' }
}
}
},
settings: {
x: { scale: 'm' },
y: { scale: 's' },
shape: 'circle',
size: () => 2,
strokeWidth: 2,
stroke: '#fff',
opacity: 0.8,
fill: { scale: 'col', ref: 'group' }
}
},
{
key: 'tooltip',
type: 'tooltip',
settings: {
duration: 10000,
extract: ({ node, resources }) => console.log(node) || node.data.value,
placement: {
type: 'pointer',
dock: 'top',
offset: 8,
area: 'viewport'
}
},
},
]
};
`;

const data = `
return [{
type: 'matrix',
data: [
['Year', 'Month', 'Sales', 'Margin'],
['2010', 'Jan', 1106, 7],
['2010', 'Feb', 5444, 53],
['2010', 'Mar', 147, 64],
['2010', 'Apr', 7499, 47],
['2010', 'May', 430, 62],
['2010', 'June', 9735, 13],
['2010', 'July', 7435, 15],
['2011', 'Jan', 1482, 45],
['2011', 'Feb', 2659, 76],
['2011', 'Mar', 1261, 73],
['2011', 'Apr', 3085, 56],
['2011', 'May', 3035, 91],
['2011', 'June', 7691, 88],
['2011', 'July', 3012, 81],
['2012', 'Jan', 7980, 61],
['2012', 'Feb', 2564, 22],
['2012', 'Mar', 7957, 98],
['2012', 'Apr', 5809, 1],
['2012', 'May', 429, 2],
['2012', 'June', 6757, 77],
['2012', 'July', 9415, 92]
]
}];
`;

const item = {
id: 'simple-tooltip',
title: 'Simple tooltip example',
code,
data,
};

export default item;
31 changes: 19 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,14 @@
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/react@^15.x || ^16.x":
version "16.9.11"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.11.tgz#70e0b7ad79058a7842f25ccf2999807076ada120"
integrity sha512-UBT4GZ3PokTXSWmdgC/GeCGEJXE5ofWyibCcecRLUVN2ZBpXQGVgQGtG2foS7CrTKFKlQVVswLvf7Js6XA/CVQ==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
Expand Down Expand Up @@ -6697,10 +6705,10 @@ monaco-editor-webpack-plugin@1.7.0:
dependencies:
"@types/webpack" "^4.4.19"

monaco-editor@0.16.2, monaco-editor@^0.16.0:
version "0.16.2"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.16.2.tgz#950084ed82eeaef1c8c9d3c1bcab849fe11b2415"
integrity sha512-NtGrFzf54jADe7qsWh3lazhS7Kj0XHkJUGBq9fA/Jbwc+sgVcyfsYF6z2AQ7hPqDC+JmdOt/OwFjBnRwqXtx6w==
monaco-editor@0.18.1:
version "0.18.1"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.18.1.tgz#ced7c305a23109875feeaf395a504b91f6358cfc"
integrity sha512-fmL+RFZ2Hrezy+X/5ZczQW51LUmvzfcqOurnkCIRFTyjdVjzR7JvENzI6+VKBJzJdPh6EYL4RoWl92b2Hrk9fw==

move-concurrently@^1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -8241,7 +8249,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.3"

prop-types@15.7.2, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@15.7.2, prop-types@^15.0.0, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -8481,14 +8489,13 @@ react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.11.0.tgz#b85dfecd48ad1ce469ff558a882ca8e8313928fa"
integrity sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==

react-monaco-editor@0.25.1:
version "0.25.1"
resolved "https://registry.yarnpkg.com/react-monaco-editor/-/react-monaco-editor-0.25.1.tgz#29215061da23d0e4ad7bf928d9403288d5be4e92"
integrity sha512-VLksQjt8fmeIZoET9fQgmR0sdCCBFaiss92MwW5JvgO3JfrnhHtrLBqrSQRjtbUmef1EmEKi4gZp5Mh0oidvVg==
react-monaco-editor@0.32.1:
version "0.32.1"
resolved "https://registry.yarnpkg.com/react-monaco-editor/-/react-monaco-editor-0.32.1.tgz#fa45d62fd19d5942cba98bd7c59336d21f8750e0"
integrity sha512-gJjU9Rx/QuJr+Y4C0MSidMdkh1hmHGneIU8yI87bc5kd46ZXPNETqiigyUB7pKy4ZSuFHBhjhg2lgESaID43ag==
dependencies:
"@types/react" "*"
monaco-editor "^0.16.0"
prop-types "^15.7.2"
"@types/react" "^15.x || ^16.x"
prop-types "^15.0.0"

react-transition-group@^4.3.0:
version "4.3.0"
Expand Down

0 comments on commit e4b4b5f

Please sign in to comment.