Echarts realizes the rotation of the moon (super simple, you can see it at a glance)

Jsnewbie 2021-09-15 04:18:33
echarts realizes rotation moon super

I'm participating in the Mid Autumn Festival Creative submission competition , Details please see : Mid Autumn Festival Creative submission contest

 Screen Recording 2021-09-07 Afternoon 4.39.14.gif
( chart 1)

( chart 2)

The inspiration for writing this case comes from the earth map of Baidu map ( chart 2), Later, I searched and used WebGL Developed , It's hard . however Since it's all visualization , I think of it. ECharts This plugin , I went directly to the official website to search . As expected 3D Found in the earth moon This plugin . Don't talk too much nonsense, just do it !

For project framework vue, After the scaffold is installed . Direct installation echarts plug-in unit
What needs to be noted here is echarts And echarts-gl Are two separate plug-ins , It needs to be installed separately , It's official

install echarts:npm install echarts --save
install echarts-gl: npm install echarts-gl

When the preparation is finished, start the code :

<div class="moon"> <span> The moon </span> <div class="mychart" ref="mychart"></div> </div>
<script> import * as echarts from 'echarts'; import 'echarts-gl'; import url from '../assets/bg3.jpeg' export default { data() { return { ROOT_PATH: '[email protected]/examples', imgurl: url, angle: 0, // The rotation angle defaults to 0, Every time s turn 10° } }, methods: { initMoon() { let myChart = echarts.init(this.$refs.mychart) let option = { globe: { baseTexture: this.ROOT_PATH + '/data-gl/asset/moon-base.jpg', heightTexture: this.ROOT_PATH + '/data-gl/asset/moon-bump.jpg', displacementScale: 0.05, displacementQuality: 'medium', environment: this.imgurl, shading: 'realistic', realisticMaterial: { roughness: 0.8, metalness: 0 }, postEffect: { enable: true, SSAO: { enable: true, radius: 2, intensity: 1, quality: 'high' } }, temporalSuperSampling: { enable: true }, light: { ambient: { intensity: 0 }, main: { intensity: 2, shadow: true }, ambientCubemap: { texture: this.ROOT_PATH + '/data-gl/asset/pisa.hdr', exposure: 0, diffuseIntensity: 0.02 } }, viewControl: { autoRotate: true, distance: 1000, // Only rotate longitudinally  // rotateSensitivity: [0, 1] } }, series: [] } myChart.setOption(option) }, }, mounted() { this.initMoon() } } </script>
<style lang="less" scoped> .moon { display: flex; flex-direction: column; align-items: center; .mychart { margin-top: 30px; width: 400px; height: 400px } } </style>
 Copy code 

vue The code structure is not explained ,so easy about echarts This plug-in briefly explains .

We use echarts To realize data visualization, in fact, the final generation is a Canvas, So before drawing, we need to prepare ECharts Prepare a high and wide DOM Containers (mychart This 400*400 Of div), The container is ready to pass  echarts.init  Method initializes one echarts example

option Configuration item
echarts There are many configuration items in , We can configure different... According to drawing different diagrams option. In general echarts The examples in will have corresponding option, We directly cv The Dharma works ok. There are several examples of the moon above option It needs to be explained

  • autoRotate -- Whether to turn on the automatic rotation of the viewing angle around the object , Its value is Boolean , Only for ture Will have the effect of automatic rotation
  • distance -- The default viewing angle is the distance from the subject , about  globe  It's the distance from the earth's surface , about  grid3D  and  geo3D  For other components, it is the distance from the central origin . That's the official explanation , To put it bluntly, this attribute defines the initial viewing angle distance ( Because of me echarts The container of is 400*400 Of , The initialized moon is large and almost fills the whole container , The LEGO astronauts behind are covered , How can the LEGO given by my girlfriend be blocked , Never !)
  • environment -- Environment mapping . Support solid color 、 gradient 、 Panoramic mapping url. This is the background picture of the starry sky , There must be no LEGO astronaut on the official website. It's me p Go up, hahaha
  • baseTexture -- The texture of the surface of the earth or moon , Here I directly use the pictures on the official website , Click here You can preview the picture directly

When the container and configuration items are ready , adopt  setOption  Method to generate a chart

Come here , A simple lunar rotation effect is done . I wish you all a happy mid autumn festival in advance , I also wish you can find the boyfriend and girlfriend who doesn't bother to fight Lego for you !


  1. Monthly salary 10K yard farmer, job hopping to 40K architect, summary of technical learning Roadmap
  2. Manually compile and deploy LNMP environment (centos7.5 + nginx-1.18.0 + mysql-5.7.30 + php-7.4.14)
  3. The drama "light" of the Republic of China premiered, with a dismal audience rating of less than 0.4, creating the worst audience rating of Hunan Satellite TV!
  4. It is said that Ericsson will cancel Nanjing R & D center
  5. Question d'entrevue commune de Spring Cloud, où est l'avenir de 2021 Java?
  6. Sharedpreferences Replacement - mmkv Integration and Principles, 27 years old Preschool Development
  7. Différence entre TCP et UDP, développement frontal mobile
  8. The whole process of mybatis dynamic proxy implementation of spring series? The correct answer rate is less than 1%
  9. Ajax Foundation
  10. Développement Android comprendre ces entrevues naturelles sans peur, Android Knowledge System
  11. L'expérience de l'entrevue d'embauche de l'école Java peut vous aider à obtenir une entrevue.
  12. Leetcode pinceau question 989 - simple - addition d'entiers sous forme de tableau
  13. Children of the Qiao family: after reading Qiao Zuwang's last selflessness, we can recognize his simple father's love
  14. Partager une petite expérience d'entrevue et obtenir un produit
  15. Solution de capture de paquets https sur la plate - forme Android et analyse des problèmes, Android développe un apprentissage complet
  16. Young people are the first choice for transportation. These hatchbacks suck countless powder. Is it your dish?
  17. "Net red granny" over 70 has countless circle powder by wearing, and is more fashionable than young people
  18. Méthodes de fonctionnement des tableaux couramment utilisées en javascript
  19. Summary of Vue knowledge points
  20. 10 septembre: deuxième visite d'une journée à Yantai, Shandong - vue nocturne de Chaoyang Street, Zhifu District
  21. Front and back end data interaction (V) -- what is Axios?
  22. Windows configures nginx to boot automatically
  23. Des questions d'entrevue communes à Tomcat pour discuter de votre compréhension de la technologie de verrouillage distribué,
  24. JS handscrap, Classic interview question, web front end Development Process
  25. Android 400 questions d'entrevue pour vous aider à entrer dans l'usine, un tour pour vous apprendre à comprendre netty
  26. Développement et projet d'application Web statique côté PC
  27. Recommandé pour le tutoriel Spring Framework, 2021 dernière question d'entrevue d'embauche de la société aiqiyi Java,
  28. La dernière revue scientifique de l'académicien Luo Liqun: architecture de la boucle neuronale pour stimuler la nouvelle Ia
  29. [partage d'expérience de travail], 2021 les dernières questions d'entrevue Java de Baidu, Headlines, etc.
  30. Lisez l'analyse de 497 questions pour l'entrevue d'ingénieur principal Android et vérifiez les lacunes.
  31. Grâce à cette collection de questions d'entrevue d'automne, le salaire de saut d'emploi et l'entrevue de développement audio et vidéo ont doublé.
  32. Prenez d'un coup l'offre de Tencent meituan et jetez un coup d'oeil à cette copie de l'entrevue de printemps!
  33. L'expérience et l'expérience d'un Maverick Java en matière d'entrevue sur les MTD, l'expérience de l'entrevue d'embauche du printemps Java en 2021,
  34. Vue中自定义列表复选框和全选框-案例
  35. Vue bidirectional binding (V-model bidirectional binding,. Sync bidirectional binding,. Sync transfer object)
  36. CSS text overflow ellipsis summary, as you wish
  37. C'est la mode la plus étrange que j'ai jamais vue.
  38. Cases à cocher et toutes les cases à cocher de la liste personnalisée en vue - CAS
  39. Vue bidirectional binding (V-model bidirectional binding,. Sync bidirectional binding,. Sync transfer object)
  40. Vue3.0 using Gaode map to obtain longitude and latitude information
  41. Front end interview daily 3 + 1 - day 877
  42. Vue bidirectional binding (V-model bidirectional binding,. Sync bidirectional binding,. Sync transfer object)
  43. React realizes the function of copying pictures with one click
  44. White space, word break and word wrap are the three most basic and confusing attributes in CSS - thoroughly understand
  45. Trois ans d'expérience d'entrevue avec une femme de programmation diplômée, une réflexion sur la cohérence de l'expiration des données de redis Master slave Node,
  46. Résumé de l'entrevue Android de Dachang, carte technique Android
  47. Un plan de carrière Java correct, découvrez les questions que vous devez poser lors de l'entrevue d'embauche du printemps Java de cette année.
  48. Le résumé de l'entrevue Android de Dachang est en retard
  49. Un article vous a appris à gérer les entrevues sur le Web, à partager 350 vraies questions d'entrevue Java,
  50. Jquery Tools Methodology collation, Sharing a little interview Experience
  51. Jquery plug - in urianchor, app front end Development
  52. $in jquery, Visualized Web Development Tool
  53. Le développement Java doit être fait. Les entrevues https demandent souvent une analyse complète.
  54. vue v-if未生效问题
  55. vue动态改变组件外部元素样式
  56. Jdk's Past Life: The Classic Features of Thin Number - java5 - - - 15 -, webfront Development
  57. Résumé des questions d'entrevue pour les ingénieurs en développement Java, analyse des questions d'entrevue à haute fréquence Dubbo,
  58. Who doesn't want to make a scratch music by himself? Scratch music is realized by native JS
  59. Learn XPath to help climb the data of major e-commerce platforms in the Mid Autumn Festival
  60. vue動態改變組件外部元素樣式