freeCodeCamp/guide/arabic/certifications/data-visualization/data-visualization-with-d3/change-styles-based-on-data/index.md

1.6 KiB

title localeTitle
Change Styles Based on Data تغيير الأنماط استنادًا إلى البيانات

تغيير الأنماط استنادًا إلى البيانات

ذكر نفسك مرة أخرى ما هي وظيفة رد الاتصال مع هذا

هناك طريقتان يمكنك من خلالهما إكمال هذا الجزء ، إما باستخدام المنطق أو المشغل الثلاثي إذا كان غير ذلك.

إذا كان آخر المنطق

مثال من w3school

`` `جافا سكريبت

const const = 50؛

إذا (مال <50) {

عودة "أنا غني" ؛

}

else {

العودة "أنا فقير" ؛

}

`What you need to remember is the bracket that the if-else logic associate with, (argument) and {statement}

Try Yourself Now 👩‍💻👨‍💻

Ternary operator

A more detailed explanation here. Ternary operator is a lot more concise and quicker to remember for a simple true or false statement. Read this `

جافا سكريبت

شرط ؟ القيمة إذا كانت صحيحة: value if false

For someone who still not sure here is a solution by using If-else statement

جافا سكريبت .style ("color"، (d) => { إذا ((د <20) { العودة "الحمراء" } else { العودة "الخضراء" } }) `` `