@@ -2181,3 +2181,63 @@ export function IntradayBreaks1() {
21812181 </ LineChart >
21822182 ) ;
21832183}
2184+
2185+ export function DatasetLink ( ) {
2186+ const chartRef = React . useRef < echarts . ECharts > ( null ) ;
2187+ const [ dimension , setDimension ] = React . useState ( '2012' ) ;
2188+
2189+ React . useEffect ( ( ) => {
2190+ const myChart = chartRef . current ;
2191+ if ( ! myChart ) return ;
2192+ const listener = ( event : any ) => {
2193+ const xAxisInfo = event . axesInfo [ 0 ] ;
2194+ if ( xAxisInfo ) {
2195+ const dimension = xAxisInfo . value + 1 ;
2196+ setDimension ( dimension ) ;
2197+ }
2198+ } ;
2199+ myChart . on ( 'updateAxisPointer' , listener ) ;
2200+ return ( ) => {
2201+ myChart . off ( 'updateAxisPointer' , listener ) ;
2202+ } ;
2203+ } , [ ] ) ;
2204+
2205+ return (
2206+ < LineChart
2207+ ref = { chartRef }
2208+ style = { { width : 480 , height : 360 } }
2209+ useUTC
2210+ xAxis = { { type : 'category' } }
2211+ yAxis = { { gridIndex : 0 } }
2212+ grid = { { top : '55%' } }
2213+ series = { [
2214+ { type : 'line' , smooth : true , seriesLayoutBy : 'row' , emphasis : { focus : 'series' } } ,
2215+ { type : 'line' , smooth : true , seriesLayoutBy : 'row' , emphasis : { focus : 'series' } } ,
2216+ { type : 'line' , smooth : true , seriesLayoutBy : 'row' , emphasis : { focus : 'series' } } ,
2217+ { type : 'line' , smooth : true , seriesLayoutBy : 'row' , emphasis : { focus : 'series' } } ,
2218+ {
2219+ type : 'pie' ,
2220+ radius : '30%' ,
2221+ center : [ '50%' , '25%' ] ,
2222+ emphasis : { focus : 'self' } ,
2223+ label : { formatter : `{b}: {@${ dimension } } ({d}%)` } ,
2224+ encode : { itemName : 'product' , value : dimension , tooltip : dimension } ,
2225+ } ,
2226+ ] }
2227+ >
2228+ < Legend legend = { { } } />
2229+ < Tooltip tooltip = { { trigger : 'axis' , showContent : false } } />
2230+ < Dataset
2231+ dataset = { {
2232+ source : [
2233+ [ 'product' , '2012' , '2013' , '2014' , '2015' , '2016' , '2017' ] ,
2234+ [ 'Milk Tea' , 56.5 , 82.1 , 88.7 , 70.1 , 53.4 , 85.1 ] ,
2235+ [ 'Matcha Latte' , 51.1 , 51.4 , 55.1 , 53.3 , 73.8 , 68.7 ] ,
2236+ [ 'Cheese Cocoa' , 40.1 , 62.2 , 69.5 , 36.4 , 45.2 , 32.5 ] ,
2237+ [ 'Walnut Brownie' , 25.2 , 37.1 , 41.2 , 18 , 33.9 , 49.1 ] ,
2238+ ] ,
2239+ } }
2240+ />
2241+ </ LineChart >
2242+ ) ;
2243+ }
0 commit comments