diff --git a/demos/0-interacion-interval-select.html b/demos/0-interacion-interval-select.html index 68c0f467d..1dad0f41d 100644 --- a/demos/0-interacion-interval-select.html +++ b/demos/0-interacion-interval-select.html @@ -5,6 +5,14 @@ 柱状图选中 +
@@ -37,6 +45,17 @@ }); chart.tooltip(false); chart.interval().position('year*sales'); + + // 绘制 guide + data.map(obj => { + chart.guide().html({ + position: [ obj.year, obj.sales ], + html: `
${obj.sales}
`, + alignX: 'center', + alignY: 'bottom' + }); + }); + chart.render(); chart.interaction('interval-select', { @@ -44,10 +63,37 @@ stroke: '#000', lineWidth: 1 }, - unSelectStyle: null, - cancelable: false, + // unSelectStyle: null, + // cancelable: true, + selectAxisStyle: { + fill: '#000', + fontWeight: 'bold' + }, onEnd(ev) { console.log(ev.data, ev.selected) + const { data, selected } = ev; + if (selected) { + $('.chart-label').each((index, el) => { + el = $(el); + if (el.data('year') === data.year) { + el.css({ + color: '#000', + }); + } else { + el.css({ + color: '#808080', + }); + } + }); + } else { + $('.chart-label').each((index, el) => { + el = $(el); + + el.css({ + color: '#808080' + }); + }); + } } }); diff --git a/demos/index.njk b/demos/index.njk index 8b3ca40a5..e4b6f22f9 100644 --- a/demos/index.njk +++ b/demos/index.njk @@ -35,8 +35,8 @@ {% endfor %}