Closed daxiongok closed 2 years ago
Hi! We've received your issue and please be patient to get responded. 🎉 The average response time is expected to be within one day for weekdays.
In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.
If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.
If you are interested in the project, you may also subscribe our mail list.
Have a nice day! 🍵
@daxiongok Please provide a demo for the issue either with https://jsfiddle.net/ovilia/n6xc4df3/ or https://gallery.echartsjs.com/editor.html.
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!
const handleZoomIn = () => { if (zoomLevel < maxZoomLevel) { zoomLevel = zoomLevel + 0.3; } chartRef.current.getEchartsInstance().setOption( { series: { zoom: zoomLevel + 0.3 } }, false ); };
same issue in here im not using state so we dont have any problem about rerender. Im trying to have a zoom button for changing the zoom level of data. but its reseting collapse and expand of tree data.
the full source: import React, { useEffect, useRef, useState } from 'react'; import ReactEChartsCore from 'echarts-for-react/lib/core'; import { TreeChart } from 'echarts/charts'; import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components'; import * as echarts from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; import { getColor } from 'helpers/utils'; import { Button, Card, Form, OverlayTrigger, Popover } from 'react-bootstrap'; import FalconCardHeader from 'components/common/FalconCardHeader'; import HelpTooltip from 'components/common/HelpTooltip'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import CardChartDropDown from 'components/common/CardChartDropDown'; import { useAppContext } from 'Main'; import { crawlTooltip } from 'tooltip/crawl/crawlTooltips'; echarts.use([ TitleComponent, TooltipComponent, GridComponent, TreeChart, CanvasRenderer ]); // تنظیمات نمودار let zoomLevel = 1; const maxZoomLevel = 20; const minZoomLevel = 0.001; const getOption = data => ({ textStyle: { fontFamily: 'dana' }, formatter: params => console.log('FORMATTER', params), // نحوه نمایش تولتیپ نمودار tooltip: { trigger: 'item', triggerOn: 'mousemove', padding: [7, 10], backgroundColor: getColor('gray-100'), borderColor: getColor('gray-300'), textStyle: { color: getColor('gray-1100'), fontSize: 8 }, borderWidth: 1, show: false, formatter: params => { return `
<span class="fw-bolder">
</div>`;
},
transitionDuration: 0,
axisPointer: {
type: 'none'
}
}, series: [ { // تنظیمات نمایشی نمودار roam: true, layout: 'orthogonal', scaleLimit: { min: minZoomLevel, max: maxZoomLevel }, type: 'tree', data: [data], top: '1%', left: '7%', bottom: '1%', itemStyle: { color: getColor('primary'), backgroundColor: 'red', borderWidth: '30px' }, right: '20%', lineStyle: { color: getColor('primary') }, label: { position: 'left', verticalAlign: 'middle', align: 'right', color: getColor('gray-1100'), border: 0, fontSize: 8, formatter: params => decodeURIComponent(params.name) }, showSymbol: true, symbol: 'emptyCircle',
symbolSize: 10,
leaves: {
label: {
position: 'right',
verticalAlign: 'middle',
align: 'left'
},
itemStyle: {
color: getColor('primary'),
borderRadius: [0, 3, 3, 0]
}
},
expandAndCollapse: true,
animationDuration: 550,
animationDurationUpdate: 750
}
] }); // نمودار درخت پایه const Tree = ({ data, layout = 'orthogonal', title = '' }) => { const chartRef = useRef(null); const [fontSize, setFontSize] = useState(8);
// کنترل ریست نمودار const handleZoomReset = () => { zoomLevel = 1; chartRef.current.getEchartsInstance().dispatchAction({ type: 'restore' }); }; // افزودن زوم نمودار const handleZoomIn = () => { if (zoomLevel < maxZoomLevel) { zoomLevel = zoomLevel + 0.3; } chartRef.current.getEchartsInstance().setOption( { series: { zoom: zoomLevel + 0.3 } }, false ); }; //کم کردن زوم نمودار const handleZoomOut = () => { if (zoomLevel > minZoomLevel) { zoomLevel = zoomLevel - 0.3; } chartRef.current.getEchartsInstance().setOption( { series: { zoom: zoomLevel - 0.3 } }, false ); };
const { config: { isDark } } = useAppContext(); const cardRef = useRef(); const handleFontChange = size => { console.log(size, chartRef?.current?.getEchartsInstance().getOption()); chartRef?.current?.getEchartsInstance().setOption({ series: [ { lable: { fontSize: size } } ] }); }; return (
); };
export default Tree;
Version
4.6.0
Steps to reproduce
I used
appendData
to load chartsData , afterwards i cant usesetOption
to set anything about chart options,its will clear my charts data!What is expected?
still i can set series option
What is actually happening?
series data will be clear.