Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:18:50+00:00 2026-05-26T15:18:50+00:00

Help! How to change Bullet Charts JavaScript code from these web-page: http://mbostock.github.com/d3/ex/bullet.html in such

  • 0

Help! How to change Bullet Charts JavaScript code from these web-page:
http://mbostock.github.com/d3/ex/bullet.html
in such a way, that the data for visualization would be taken not from “bullets.json” (d3.json(“bullets.json”, function(data) {) , but it would be already as a variable in the source code.
My solution doesn’t work:

var data = [{title: "Revenue", subtitle: "", ranges: [0,0,0], measures: [220,270], markers: [0] },                //!!!
        {title: "Profit" , subtitle: "", ranges: [0,0,0], measures: [21,23]  , markers: [0] } ];  

Source Code:

<html>
<head>
<title>Bullet Charts</title>
<script type="text/javascript" src="../../d3.js"></script>
<script type="text/javascript" src="../../d3.chart.js"></script>
<link type="text/css" rel="stylesheet" href="../button.css"/>
<link type="text/css" rel="stylesheet" href="bullet.css"/>
</head>
<body>
<div id="chart">
  <button class="first last" onclick="transition()">
    Update
  </button><p>
</div>
<script> 
var w = 960,
h = 50,
m = [5, 40, 20, 120]; // top right bottom left

var chart = d3.chart.bullet()
.width(w - m[1] - m[3])
.height(h - m[0] - m[2]);

 //d3.json("bullets.json", function(data) {

 var data = [{title: "Revenue", subtitle: "", ranges: [0,0,0], measures: [220,270],  markers: [0] },                //!!!
        {title: "Profit" , subtitle: "", ranges: [0,0,0], measures: [21,23]  ,  markers: [0] } ];              //!!!

 var vis = d3.select("#chart").selectAll("svg")
  .data(data)
.enter().append("svg:svg")
  .attr("class", "bullet")
  .attr("width", w)
  .attr("height", h)
.append("svg:g")
  .attr("transform", "translate(" + m[3] + "," + m[0] + ")")
  .call(chart);

 var title = vis.append("svg:g")
  .attr("text-anchor", "end")
  .attr("transform", "translate(-6," + (h - m[0] - m[2]) / 2 + ")");

  title.append("svg:text")
  .attr("class", "title")
  .text(function(d) { return d.title; });

  title.append("svg:text")
  .attr("class", "subtitle")
  .attr("dy", "1em")
  .text(function(d) { return d.subtitle; });

  chart.duration(1000);
 window.transition = function() {
 vis.map(randomize).call(chart);
 };
 }
 );

 function randomize(d) {
 if (!d.randomizer) d.randomizer = randomizer(d);
 d.ranges = d.ranges.map(d.randomizer);
 d.markers = d.markers.map(d.randomizer);
 d.measures = d.measures.map(d.randomizer);
 return d;
 }

 function randomizer(d) {
 var k = d3.max(d.ranges) * .2;
 return function(d) {
 return Math.max(0, d + k * (Math.random() - .5));
 };
 }

 </script>
  </body>
 </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:18:51+00:00Added an answer on May 26, 2026 at 3:18 pm

    after var data = [{title: “(…) type:

    data = JSON.stringify(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got page to edit some html code from db, to do that I
I have the javascript code below which disables an asp.net button during page postback.
Can anyone help me change this code back to a simple for loop? public
anybody can help me to change that javascript function to AS3? thanks :) function
I'm relatively new to Cocoa/ObjC. Could someone please help me change my code to
can someone please help me on how to change the button background from white
How I Change Complete Url In asp.net with help of url rewriting?
Is there a way to change the context sensitive help in Visual Studio so
Help! I have an Axis web service that is being consumed by a C#
Help me ..my page index is not working in visual studio. my page load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.